commit
eff9736db2
@ -0,0 +1,249 @@ |
||||
package com.bweb.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hai.common.exception.ErrorCode; |
||||
import com.hai.common.exception.ErrorHelp; |
||||
import com.hai.common.exception.SysCode; |
||||
import com.hai.common.security.UserCenter; |
||||
import com.hai.common.utils.ResponseMsgUtil; |
||||
import com.hai.config.SpPrinterConfig; |
||||
import com.hai.entity.*; |
||||
import com.hai.enum_type.DeviceTypeEnum; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.model.UserInfoModel; |
||||
import com.hai.service.BsCompanyService; |
||||
import com.hai.service.HighDeviceService; |
||||
import com.hai.service.HighMerchantService; |
||||
import com.hai.service.HighMerchantStoreService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
@Controller |
||||
@RequestMapping(value = "/device") |
||||
@Api(value = "卡卷接口") |
||||
public class HighDeviceController { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(HighCouponController.class); |
||||
|
||||
@Resource |
||||
private UserCenter userCenter; |
||||
|
||||
@Resource |
||||
private HighDeviceService deviceService; |
||||
|
||||
@Resource |
||||
private HighMerchantService merchantService; |
||||
|
||||
@Resource |
||||
private HighMerchantStoreService merchantStoreService; |
||||
|
||||
@Resource |
||||
private BsCompanyService companyService; |
||||
|
||||
@RequestMapping(value="/editDevice",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "编辑设备") |
||||
public ResponseData editDevice(@RequestBody HighDevice body) { |
||||
try { |
||||
|
||||
if (body.getMerStoreId() == null |
||||
|| body.getType() == null |
||||
|| StringUtils.isBlank(body.getDeviceName()) |
||||
) { |
||||
log.error("HighDeviceController -> editDevice() error!","参数错误"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
if (DeviceTypeEnum.getNameByType(body.getType()) == null) { |
||||
log.error("HighDeviceController -> editDevice() error!","参数错误"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的设备类型"); |
||||
} |
||||
|
||||
if (body.getType().equals(DeviceTypeEnum.type1.getType()) |
||||
&& (StringUtils.isBlank(body.getDeviceSn()) || StringUtils.isBlank(body.getDeviceKey()))) { |
||||
log.error("HighDeviceController -> editDevice() error!","参数错误"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
|
||||
} else if (body.getType().equals(DeviceTypeEnum.type2.getType()) |
||||
&& (StringUtils.isBlank(body.getDeviceImei()) || StringUtils.isBlank(body.getDeviceIccid()))) { |
||||
log.error("HighDeviceController -> editDevice() error!","参数错误"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
HighDevice device; |
||||
if (body.getId() != null) { |
||||
// 查询设备
|
||||
device = deviceService.getDetailById(body.getId()); |
||||
if (device == null) { |
||||
log.error("HighDeviceController -> editDevice() error!","参数错误"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
} else { |
||||
device = new HighDevice(); |
||||
} |
||||
|
||||
// 查询门店
|
||||
HighMerchantStore store = merchantStoreService.getDetailById(body.getMerStoreId()); |
||||
if (store == null) { |
||||
log.error("HighDeviceController -> editDevice() error!","参数错误"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的门店"); |
||||
} |
||||
|
||||
// 查询商户
|
||||
HighMerchant merchant = merchantService.getDetailById(store.getMerchantId()); |
||||
if (merchant == null) { |
||||
log.error("HighDeviceController -> editDevice() error!","参数错误"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商户"); |
||||
} |
||||
|
||||
// 查询分公司
|
||||
BsCompany company = companyService.getCompanyById(merchant.getCompanyId()); |
||||
if (company == null) { |
||||
log.error("HighDeviceController -> editDevice() error!","参数错误"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的分公司"); |
||||
} |
||||
|
||||
if (body.getType().equals(DeviceTypeEnum.type1.getType())) { |
||||
SpPrinterConfig sp = new SpPrinterConfig(); |
||||
JSONObject jsonObject = JSONObject.parseObject(sp.addPrinter(body.getDeviceSn(), body.getDeviceKey(), body.getDeviceName())); |
||||
if (!jsonObject.getInteger("errorcode").equals(0)) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("errormsg")); |
||||
} |
||||
} |
||||
|
||||
device.setCompanyId(company.getId()); |
||||
device.setCompanyName(company.getName()); |
||||
device.setMerId(merchant.getId()); |
||||
device.setMerName(merchant.getMerchantName()); |
||||
device.setMerStoreId(store.getId()); |
||||
device.setMerStoreName(store.getStoreName()); |
||||
device.setType(body.getType()); |
||||
device.setDeviceName(body.getDeviceName()); |
||||
device.setDeviceSn(body.getDeviceSn()); |
||||
device.setDeviceKey(body.getDeviceKey()); |
||||
device.setDeviceImei(body.getDeviceImei()); |
||||
device.setDeviceIccid(body.getDeviceIccid()); |
||||
deviceService.editDevice(device); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighDeviceController -> editDevice() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/delDevice",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "删除设备") |
||||
public ResponseData delDevice(@RequestBody JSONObject body) { |
||||
try { |
||||
|
||||
if (body.getLong("deviceId") == null) { |
||||
log.error("HighDeviceController -> delDevice() error!","参数错误"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
// 查询设备
|
||||
HighDevice device = deviceService.getDetailById(body.getLong("deviceId")); |
||||
if (device == null) { |
||||
log.error("HighDeviceController -> delDevice() error!","参数错误"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
if (device.getType().equals(DeviceTypeEnum.type1.getType())) { |
||||
SpPrinterConfig sp = new SpPrinterConfig(); |
||||
JSONObject jsonObject = JSONObject.parseObject(sp.deletePrinter(device.getDeviceSn())); |
||||
if (!jsonObject.getInteger("errorcode").equals(0)) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("errormsg")); |
||||
} |
||||
} |
||||
|
||||
device.setStatus(0); |
||||
deviceService.editDevice(device); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighDeviceController -> delDevice() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/getDetailById",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "根据id查询设备详情") |
||||
public ResponseData getDetailById(@RequestParam(name = "deviceId", required = true) Long deviceId) { |
||||
try { |
||||
|
||||
return ResponseMsgUtil.success(deviceService.getDetailById(deviceId)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighDeviceController -> getDetailById() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/getDeviceList",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "根据id查询设备详情") |
||||
public ResponseData getDeviceList(@RequestParam(name = "companyId", required = false) Long companyId, |
||||
@RequestParam(name = "merId", required = false) Long merId, |
||||
@RequestParam(name = "storeId", required = false) Long storeId, |
||||
@RequestParam(name = "deviceName", required = false) String deviceName, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize) { |
||||
try { |
||||
|
||||
UserInfoModel sessionModel = userCenter.getSessionModel(UserInfoModel.class); |
||||
if (sessionModel == null) { |
||||
log.error("HighDeviceController -> getDeviceList() error!",""); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到"); |
||||
} |
||||
|
||||
Map<String, Object> param = new HashMap<>(); |
||||
param.put("deviceName", deviceName); |
||||
|
||||
if (sessionModel.getSecUser().getObjectType().equals(0)) { |
||||
param.put("companyId", companyId); |
||||
param.put("merId", merId); |
||||
param.put("storeId", storeId); |
||||
|
||||
} else if (sessionModel.getSecUser().getObjectType().equals(1)) { |
||||
param.put("companyId", sessionModel.getBsCompany().getId()); |
||||
param.put("merId", merId); |
||||
param.put("storeId", storeId); |
||||
|
||||
} else if (sessionModel.getSecUser().getObjectType().equals(2)) { |
||||
param.put("merId", sessionModel.getMerchant().getId()); |
||||
param.put("storeId", storeId); |
||||
|
||||
} else if (sessionModel.getSecUser().getObjectType().equals(3)) { |
||||
param.put("storeId", sessionModel.getMerchantStore().getId()); |
||||
|
||||
} else { |
||||
log.error("HighDeviceController -> getDeviceList() error!",""); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); |
||||
} |
||||
|
||||
PageHelper.startPage(pageNum, pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(deviceService.getDeviceList(param))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighDeviceController -> getDeviceList() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
} |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,39 @@ |
||||
package com.hai.config; |
||||
|
||||
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; |
||||
import org.eclipse.paho.client.mqttv3.MqttCallback; |
||||
import org.eclipse.paho.client.mqttv3.MqttMessage; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
@Configuration |
||||
public class MqttProviderCallBack implements MqttCallback { |
||||
|
||||
/** |
||||
* 与服务器断开 |
||||
* @param throwable |
||||
*/ |
||||
@Override |
||||
public void connectionLost(Throwable throwable) { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 消息到达回调 |
||||
* @param s |
||||
* @param mqttMessage |
||||
* @throws Exception |
||||
*/ |
||||
@Override |
||||
public void messageArrived(String s, MqttMessage mqttMessage) throws Exception { |
||||
System.out.println("消息到达"); |
||||
} |
||||
|
||||
/** |
||||
* 消息发布成功回调 |
||||
* @param iMqttDeliveryToken |
||||
*/ |
||||
@Override |
||||
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) { |
||||
System.out.println("消息发布"); |
||||
} |
||||
} |
@ -0,0 +1,208 @@ |
||||
package com.hai.config; |
||||
|
||||
import io.netty.handler.codec.mqtt.MqttConnAckVariableHeader; |
||||
import io.netty.handler.codec.mqtt.MqttConnectVariableHeader; |
||||
import io.netty.handler.codec.mqtt.MqttMessageIdVariableHeader; |
||||
import io.netty.handler.codec.mqtt.MqttPublishVariableHeader; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import javax.annotation.PostConstruct; |
||||
import org.eclipse.paho.client.mqttv3.*; |
||||
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
@Configuration |
||||
@Slf4j |
||||
public class MqttProviderConfig { |
||||
// @Value("${spring.mqtt.username}")
|
||||
private String username; |
||||
|
||||
// @Value("${spring.mqtt.password}")
|
||||
private String password; |
||||
|
||||
// @Value("${spring.mqtt.url}")
|
||||
private String hostUrl; |
||||
|
||||
/* @Value("${spring.mqtt.client.id}") |
||||
private String clientId; |
||||
|
||||
@Value("${spring.mqtt.default.topic}") |
||||
private String defaultTopic;*/ |
||||
|
||||
/** |
||||
* 客户端对象 |
||||
*/ |
||||
private MqttClient client; |
||||
|
||||
/** |
||||
* 在bean初始化后连接到服务器 |
||||
*/ |
||||
// @PostConstruct
|
||||
public void init() { |
||||
connect("provider-" + System.currentTimeMillis()); |
||||
} |
||||
/* |
||||
@PostConstruct |
||||
public void init(String clientId) { |
||||
connect(clientId); |
||||
}*/ |
||||
|
||||
/** |
||||
* 客户端连接服务端 |
||||
*/ |
||||
public void connect(String clientId){ |
||||
try{ |
||||
//创建MQTT客户端对象
|
||||
client = new MqttClient(hostUrl,clientId,new MemoryPersistence()); |
||||
//连接设置
|
||||
MqttConnectOptions options = new MqttConnectOptions(); |
||||
//是否清空session,设置false表示服务器会保留客户端的连接记录(订阅主题,qos),客户端重连之后能获取到服务器在客户端断开连接期间推送的消息
|
||||
//设置为true表示每次连接服务器都是以新的身份
|
||||
options.setCleanSession(true); |
||||
//设置连接用户名
|
||||
options.setUserName(username); |
||||
//设置连接密码
|
||||
options.setPassword(password.toCharArray()); |
||||
//设置超时时间,单位为秒
|
||||
options.setConnectionTimeout(100); |
||||
//设置心跳时间 单位为秒,表示服务器每隔 1.5*20秒的时间向客户端发送心跳判断客户端是否在线
|
||||
options.setKeepAliveInterval(20); |
||||
// 设置遗嘱消息的话题,若客户端和服务器之间的连接意外断开,服务器将发布客户端的遗嘱信息
|
||||
// options.setWill("willTopic",(clientId + "与服务器断开连接").getBytes(),0,false);
|
||||
//设置回调
|
||||
client.setCallback(new MqttProviderCallBack()); |
||||
client.connect(options); |
||||
} catch(MqttException e){ |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
public void publish(int qos,boolean retained,String topic,String message) { |
||||
if (client == null) { |
||||
init(); |
||||
} |
||||
try { |
||||
MqttMessage mqttMessage = new MqttMessage(); |
||||
mqttMessage.setQos(qos); |
||||
mqttMessage.setRetained(retained); |
||||
mqttMessage.setPayload(message.getBytes("UTF-8")); |
||||
// 主题的目的地,用于发布/订阅信息
|
||||
MqttTopic mqttTopic = client.getTopic(topic); |
||||
//提供一种机制来跟踪消息的传递进度
|
||||
//用于在以非阻塞方式(在后台运行)执行发布是跟踪消息的传递进度
|
||||
MqttDeliveryToken token; |
||||
//将指定消息发布到主题,但不等待消息传递完成,返回的token可用于跟踪消息的传递状态
|
||||
//一旦此方法干净地返回,消息就已被客户端接受发布,当连接可用,将在后台完成消息传递。
|
||||
token = mqttTopic.publish(mqttMessage); |
||||
token.waitForCompletion(); |
||||
|
||||
} catch (MqttException e) { |
||||
e.printStackTrace(); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
public static void main(String[] args) { |
||||
System.out.println(sendPrinterRrCodeBytest("1213131", 1)); |
||||
} |
||||
|
||||
public static byte[] sendPrinterRrCodeBytest(String printText, int pageCount) { |
||||
try { |
||||
byte[] by = printText.getBytes(); |
||||
byte[] msgByte = new byte[by.length + 16]; |
||||
// 写入缓存
|
||||
msgByte[0] = 29; |
||||
msgByte[1] = 40; |
||||
msgByte[2] = 107; |
||||
msgByte[3] = (byte)(by.length+3); |
||||
msgByte[4] = 0; |
||||
msgByte[5] = 49; |
||||
msgByte[6] = 80; |
||||
msgByte[7] = 48; // (byte)0x30);
|
||||
int index = 7; |
||||
for (int i = 0; i < by.length; i++) |
||||
{ |
||||
index = index+1; |
||||
msgByte[index] = by[i]; |
||||
} |
||||
// 打印缓存中的数据
|
||||
msgByte[index + 1] = 29; |
||||
msgByte[index + 2] = 40; |
||||
msgByte[index + 3] = 107; |
||||
msgByte[index + 4] = (byte)(by.length+3); |
||||
msgByte[index + 5] = 0; |
||||
msgByte[index + 6] = 49; |
||||
msgByte[index + 7] = 81; |
||||
msgByte[index + 8] = 48; // (byte)0x30);
|
||||
byte[] array = new byte[msgByte.length + 9]; |
||||
array[0] = 30; |
||||
array[1] = 16; |
||||
array[2] =(byte) pageCount;//打印份数
|
||||
int num = array.length - 5; |
||||
array[3] = (byte)(num >> 8); |
||||
//array[4] = (byte)((uint)num & 0xFFu);
|
||||
array[4] = (byte)(num & 0xFF); |
||||
for (int i = 0; i < msgByte.length; i++) |
||||
{ |
||||
array[i+ 5] = msgByte[i]; |
||||
} |
||||
array[array.length - 4] = 27; |
||||
array[array.length - 3] = 99; |
||||
byte[] crc16CodeArray = getCRC(msgByte); |
||||
array[array.length - 2] = crc16CodeArray[0]; |
||||
array[array.length - 1] = crc16CodeArray[1]; |
||||
return array; |
||||
} catch (Exception ex) { |
||||
System.out.println(ex.getStackTrace()); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
|
||||
private static byte[] getCRC(byte[] bytes) { |
||||
int crc = 0xFFFF; // 初始值
|
||||
for (byte b : bytes) { |
||||
crc = (crc >> 8) ^ CRC16Table[(crc ^ b) & 0xff]; |
||||
} |
||||
byte[] b = new byte[2]; |
||||
b[0] = (byte) ((crc >> 8)^0xff); |
||||
b[1] = (byte) ((crc & 0xff)^0xff); |
||||
return b; |
||||
} |
||||
|
||||
private static int[] CRC16Table = { 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, |
||||
0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, |
||||
0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, |
||||
0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, |
||||
0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, |
||||
0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, |
||||
0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, |
||||
0x662e, 0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, |
||||
0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, |
||||
0x15a9, 0x2732, 0x36bb, 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, |
||||
0x99e1, 0xab7a, 0xbaf3, 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, |
||||
0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, |
||||
0x8960, 0xbbfb, 0xaa72, 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, |
||||
0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, |
||||
0xb8e3, 0x8a78, 0x9bf1, 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, |
||||
0x242a, 0x16b1, 0x0738, 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, |
||||
0xa862, 0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, |
||||
0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, |
||||
0x5fed, 0x6d76, 0x7cff, 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, |
||||
0xc324, 0xf1bf, 0xe036, 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, |
||||
0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, |
||||
0xf2a7, 0xc03c, 0xd1b5, 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, |
||||
0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, |
||||
0xe226, 0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, |
||||
0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, |
||||
0x91a1, 0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, |
||||
0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, |
||||
0x8120, 0xb3bb, 0xa232, 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, |
||||
0x0d68, 0x3ff3, 0x2e7a, 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, |
||||
0xb0a3, 0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, |
||||
0x3ceb, 0x0e70, 0x1ff9, 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, |
||||
0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, |
||||
0x2c6a, 0x1ef1, 0x0f78 }; |
||||
} |
||||
|
@ -0,0 +1,219 @@ |
||||
package com.hai.config; |
||||
|
||||
|
||||
import org.junit.Test; |
||||
|
||||
import java.io.UnsupportedEncodingException; |
||||
|
||||
|
||||
public class PrintDemo { |
||||
|
||||
|
||||
private String accessKeyId = "LTAI5tHHL3z6gpJbMmCg3zt2"; |
||||
private String accessKeySecret = "CC9kAuqgdjKiE6jxSQHddFxGDCTpBQ"; |
||||
private String instanceId = "post-cn-i7m2558ze01"; |
||||
private String topic = "Box"; |
||||
private String groupId= "GID_BOX"; |
||||
private String endpoint= "onsmqtt.mq-internet-access.aliyuncs.com"; |
||||
|
||||
|
||||
public static final int PAYTYPE_VOICE_NULL=2000; |
||||
public static final int PAYTYPE_VOICE_ALI=2001; |
||||
public static final int PAYTYPE_VOICE_QQ=2002; |
||||
public static final int PAYTYPE_VOICE_WECHAT=2003; |
||||
public static final int PAYTYPE_VOICE_JD=2004; |
||||
public static final int PAYTYPE_VOICE_UNION=2005; |
||||
public static final int PAYTYPE_VOICE_DIY7570=7570; |
||||
public static final int PAYTYPE_VOICE_DIY7571=7571; |
||||
public static final int PAYTYPE_VOICE_DIY7572=7572; |
||||
public static final int PAYTYPE_VOICE_DIY7573=7573; |
||||
public static final int PAYTYPE_VOICE_DIY7574=7574; |
||||
public static final int PAYTYPE_VOICE_DIY7575=7575; |
||||
public static final int PAYTYPE_VOICE_DIY7576=7576; |
||||
public static final int PAYTYPE_VOICE_DIY7577=7577; |
||||
public static final int PAYTYPE_VOICE_DIY7578=7578; |
||||
public static final int PAYTYPE_VOICE_DIY7579=7579; |
||||
|
||||
|
||||
|
||||
@Test |
||||
public void Test(){ |
||||
String imeiStr="352736082440754";//设备IMEI
|
||||
String printText="1234\r\n";//打印文本
|
||||
String voiceMsgId="2019022611153312312345";//消息ID
|
||||
String voiceMsgMoney="1234";//播报金额
|
||||
//获取打印内容
|
||||
byte[] printData = getPrinterBytes(printText, 1, ""); |
||||
System.out.println(bytes2Hex(printData)); |
||||
//获取播报字符串
|
||||
System.out.println(getStaticVoiceStr(imeiStr,voiceMsgId,voiceMsgMoney,PAYTYPE_VOICE_ALI)); |
||||
//获取播报打印机指令
|
||||
printData=getPrinterVoiceBytes(printText,1,"",imeiStr,voiceMsgId,voiceMsgMoney,PAYTYPE_VOICE_ALI); |
||||
System.out.println(bytes2Hex(printData)); |
||||
/* |
||||
try { |
||||
com.aliyun.onsmqtt20200420.Client client = createClient(accessKeyId, accessKeySecret); |
||||
SendMessageRequest sendMessageRequest = new SendMessageRequest() |
||||
.setInstanceId("post-cn-i7m2558ze01") |
||||
.setMqttTopic("Box/p2p/GID_BOX@@@359ac67b25c11b8") |
||||
.setPayload(bytes2Hex(printData)); |
||||
SendMessageResponse sendMessageResponse = client.sendMessage(sendMessageRequest); |
||||
System.out.println(sendMessageResponse.getBody().msgId); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
}*/ |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 使用AK&SK初始化账号Client |
||||
* @param accessKeyId |
||||
* @param accessKeySecret |
||||
* @return Client |
||||
* @throws Exception |
||||
*/ |
||||
/* public com.aliyun.onsmqtt20200420.Client createClient(String accessKeyId, String accessKeySecret) throws Exception { |
||||
Config config = new Config() |
||||
// 您的AccessKey ID
|
||||
.setAccessKeyId(accessKeyId) |
||||
// 您的AccessKey Secret
|
||||
.setAccessKeySecret(accessKeySecret); |
||||
// 访问的域名
|
||||
config.endpoint = endpoint; |
||||
return new com.aliyun.onsmqtt20200420.Client(config); |
||||
}*/ |
||||
|
||||
|
||||
|
||||
/** |
||||
* 支付播报固定语音字节数组 |
||||
* @param imeiStr IMEI设备唯一标识 |
||||
* @param msgId 交易序列号,不大于32字节,保证唯一 |
||||
* @param moneyStr 播报金额,最多两位小数 |
||||
* @param payType 支付类型 |
||||
* @return |
||||
*/ |
||||
public static byte[] getStaticVoiceBytes(String imeiStr,String msgId,String moneyStr,int payType){ |
||||
return getStaticVoiceStr(imeiStr,msgId,moneyStr,payType).getBytes(); |
||||
} |
||||
/** |
||||
* 支付播报固定语音字符串 |
||||
* @param imeiStr IMEI设备唯一标识 |
||||
* @param msgId 交易序列号,不大于32字节,保证唯一 |
||||
* @param moneyStr 播报金额,最多两位小数 |
||||
* @param payType 支付类型 |
||||
* @return |
||||
*/ |
||||
public static String getStaticVoiceStr(String imeiStr,String msgId,String moneyStr,int payType){ |
||||
String str=imeiStr+"|1007|"+msgId+"|"+moneyStr+"|"+payType; |
||||
return str; |
||||
} |
||||
/** |
||||
* 获取打印内容,适用于云打印机 |
||||
* @param printText 打印文本 |
||||
* @param pageCount 打印联数 |
||||
* @param encodingStr 编码方式,默认UTF-8 |
||||
* @return |
||||
*/ |
||||
public static byte[] getPrinterBytes(final String printText, |
||||
final int pageCount, String encodingStr) { |
||||
try { |
||||
if(encodingStr.equals("")){ |
||||
encodingStr="UTF-8"; |
||||
} |
||||
byte[] msgByte = printText.getBytes(encodingStr); |
||||
// 消息数组
|
||||
final byte[] dataByte = new byte[msgByte.length + 9]; |
||||
dataByte[0] = 0x1E; |
||||
dataByte[1] = 0x10; |
||||
dataByte[2] = (byte) pageCount;// 打印多联
|
||||
// 有效数据长度
|
||||
final int len = dataByte.length - 5; |
||||
dataByte[3] = (byte) (len >> 8); |
||||
dataByte[4] = (byte) (len & 0xff); |
||||
// 数据内容
|
||||
System.arraycopy(msgByte, 0, dataByte, 5, msgByte.length); |
||||
// 标识字节
|
||||
dataByte[dataByte.length - 4] = 0x1b; |
||||
dataByte[dataByte.length - 3] = 0x63; |
||||
// 打印内容CRC校验
|
||||
final byte[] dtCRC = getCRC(msgByte); |
||||
dataByte[dataByte.length - 2] = (byte) (dtCRC[0]); |
||||
dataByte[dataByte.length - 1] = (byte) (dtCRC[1]); |
||||
msgByte = dataByte; |
||||
return msgByte; |
||||
} catch (Exception ex) { |
||||
System.out.println(ex.getStackTrace()); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public static byte[] getPrinterVoiceBytes(String printTxt,int pageCount,String encodingStr,String imeiStr,String msgId,String moneyStr,int payType){ |
||||
byte[] voiceArray=getStaticVoiceBytes(imeiStr, msgId, moneyStr, payType); |
||||
byte[] printerArray=getPrinterBytes(printTxt,pageCount,encodingStr); |
||||
byte[] data=new byte[voiceArray.length+printerArray.length]; |
||||
System.arraycopy(printerArray, 0, data, 0, printerArray.length); |
||||
System.arraycopy(voiceArray, 0, data, printerArray.length, voiceArray.length); |
||||
return data; |
||||
} |
||||
|
||||
private static int[] CRC16Table = { 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, |
||||
0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, |
||||
0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, |
||||
0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, |
||||
0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, |
||||
0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, |
||||
0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, |
||||
0x662e, 0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, |
||||
0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, |
||||
0x15a9, 0x2732, 0x36bb, 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, |
||||
0x99e1, 0xab7a, 0xbaf3, 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, |
||||
0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, |
||||
0x8960, 0xbbfb, 0xaa72, 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, |
||||
0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, |
||||
0xb8e3, 0x8a78, 0x9bf1, 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, |
||||
0x242a, 0x16b1, 0x0738, 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, |
||||
0xa862, 0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, |
||||
0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, |
||||
0x5fed, 0x6d76, 0x7cff, 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, |
||||
0xc324, 0xf1bf, 0xe036, 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, |
||||
0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, |
||||
0xf2a7, 0xc03c, 0xd1b5, 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, |
||||
0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, |
||||
0xe226, 0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, |
||||
0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, |
||||
0x91a1, 0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, |
||||
0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, |
||||
0x8120, 0xb3bb, 0xa232, 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, |
||||
0x0d68, 0x3ff3, 0x2e7a, 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, |
||||
0xb0a3, 0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, |
||||
0x3ceb, 0x0e70, 0x1ff9, 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, |
||||
0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, |
||||
0x2c6a, 0x1ef1, 0x0f78 }; |
||||
private static byte[] getCRC(byte[] bytes) { |
||||
int crc = 0xFFFF; // 初始值
|
||||
for (byte b : bytes) { |
||||
crc = (crc >> 8) ^ CRC16Table[(crc ^ b) & 0xff]; |
||||
} |
||||
byte[] b = new byte[2]; |
||||
b[0] = (byte) ((crc >> 8)^0xff); |
||||
b[1] = (byte) ((crc & 0xff)^0xff); |
||||
return b; |
||||
} |
||||
private static final char[] HEXES = { '0', '1', '2', '3', '4', '5', '6', |
||||
'7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; |
||||
/** |
||||
* byte数组 转换成 16进制小写字符串 |
||||
*/ |
||||
private static String bytes2Hex(byte[] bytes) { |
||||
if (bytes == null || bytes.length == 0) { |
||||
return null; |
||||
} |
||||
StringBuilder hex = new StringBuilder(); |
||||
for (byte b : bytes) { |
||||
hex.append(HEXES[(b >> 4) & 0x0F]); |
||||
hex.append(HEXES[b & 0x0F]); |
||||
} |
||||
return hex.toString(); |
||||
} |
||||
} |
@ -0,0 +1,155 @@ |
||||
package com.hai.dao; |
||||
|
||||
import com.hai.entity.HighDevice; |
||||
import com.hai.entity.HighDeviceExample; |
||||
import java.util.List; |
||||
import org.apache.ibatis.annotations.Delete; |
||||
import org.apache.ibatis.annotations.DeleteProvider; |
||||
import org.apache.ibatis.annotations.Insert; |
||||
import org.apache.ibatis.annotations.InsertProvider; |
||||
import org.apache.ibatis.annotations.Options; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.apache.ibatis.annotations.Result; |
||||
import org.apache.ibatis.annotations.Results; |
||||
import org.apache.ibatis.annotations.Select; |
||||
import org.apache.ibatis.annotations.SelectProvider; |
||||
import org.apache.ibatis.annotations.Update; |
||||
import org.apache.ibatis.annotations.UpdateProvider; |
||||
import org.apache.ibatis.type.JdbcType; |
||||
import org.springframework.stereotype.Repository; |
||||
|
||||
/** |
||||
* |
||||
* 代码由工具生成,请勿修改!!! |
||||
* 如果需要扩展请在其父类进行扩展 |
||||
* |
||||
**/ |
||||
@Repository |
||||
public interface HighDeviceMapper extends HighDeviceMapperExt { |
||||
@SelectProvider(type=HighDeviceSqlProvider.class, method="countByExample") |
||||
long countByExample(HighDeviceExample example); |
||||
|
||||
@DeleteProvider(type=HighDeviceSqlProvider.class, method="deleteByExample") |
||||
int deleteByExample(HighDeviceExample example); |
||||
|
||||
@Delete({ |
||||
"delete from high_device", |
||||
"where id = #{id,jdbcType=BIGINT}" |
||||
}) |
||||
int deleteByPrimaryKey(Long id); |
||||
|
||||
@Insert({ |
||||
"insert into high_device (`type`, company_id, ", |
||||
"company_name, mer_id, ", |
||||
"mer_name, mer_store_id, ", |
||||
"mer_store_name, device_name, ", |
||||
"device_sn, device_key, ", |
||||
"device_imei, device_iccid, ", |
||||
"`status`, create_time, ", |
||||
"update_time, ext_1, ", |
||||
"ext_2, ext_3)", |
||||
"values (#{type,jdbcType=INTEGER}, #{companyId,jdbcType=BIGINT}, ", |
||||
"#{companyName,jdbcType=VARCHAR}, #{merId,jdbcType=BIGINT}, ", |
||||
"#{merName,jdbcType=VARCHAR}, #{merStoreId,jdbcType=BIGINT}, ", |
||||
"#{merStoreName,jdbcType=VARCHAR}, #{deviceName,jdbcType=VARCHAR}, ", |
||||
"#{deviceSn,jdbcType=VARCHAR}, #{deviceKey,jdbcType=VARCHAR}, ", |
||||
"#{deviceImei,jdbcType=VARCHAR}, #{deviceIccid,jdbcType=VARCHAR}, ", |
||||
"#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", |
||||
"#{updateTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ", |
||||
"#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" |
||||
}) |
||||
@Options(useGeneratedKeys=true,keyProperty="id") |
||||
int insert(HighDevice record); |
||||
|
||||
@InsertProvider(type=HighDeviceSqlProvider.class, method="insertSelective") |
||||
@Options(useGeneratedKeys=true,keyProperty="id") |
||||
int insertSelective(HighDevice record); |
||||
|
||||
@SelectProvider(type=HighDeviceSqlProvider.class, method="selectByExample") |
||||
@Results({ |
||||
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), |
||||
@Result(column="type", property="type", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT), |
||||
@Result(column="company_name", property="companyName", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="mer_id", property="merId", jdbcType=JdbcType.BIGINT), |
||||
@Result(column="mer_name", property="merName", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="mer_store_id", property="merStoreId", jdbcType=JdbcType.BIGINT), |
||||
@Result(column="mer_store_name", property="merStoreName", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="device_name", property="deviceName", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="device_sn", property="deviceSn", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="device_key", property="deviceKey", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="device_imei", property="deviceImei", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="device_iccid", property="deviceIccid", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), |
||||
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), |
||||
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) |
||||
}) |
||||
List<HighDevice> selectByExample(HighDeviceExample example); |
||||
|
||||
@Select({ |
||||
"select", |
||||
"id, `type`, company_id, company_name, mer_id, mer_name, mer_store_id, mer_store_name, ", |
||||
"device_name, device_sn, device_key, device_imei, device_iccid, `status`, create_time, ", |
||||
"update_time, ext_1, ext_2, ext_3", |
||||
"from high_device", |
||||
"where id = #{id,jdbcType=BIGINT}" |
||||
}) |
||||
@Results({ |
||||
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), |
||||
@Result(column="type", property="type", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT), |
||||
@Result(column="company_name", property="companyName", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="mer_id", property="merId", jdbcType=JdbcType.BIGINT), |
||||
@Result(column="mer_name", property="merName", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="mer_store_id", property="merStoreId", jdbcType=JdbcType.BIGINT), |
||||
@Result(column="mer_store_name", property="merStoreName", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="device_name", property="deviceName", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="device_sn", property="deviceSn", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="device_key", property="deviceKey", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="device_imei", property="deviceImei", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="device_iccid", property="deviceIccid", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), |
||||
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), |
||||
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) |
||||
}) |
||||
HighDevice selectByPrimaryKey(Long id); |
||||
|
||||
@UpdateProvider(type=HighDeviceSqlProvider.class, method="updateByExampleSelective") |
||||
int updateByExampleSelective(@Param("record") HighDevice record, @Param("example") HighDeviceExample example); |
||||
|
||||
@UpdateProvider(type=HighDeviceSqlProvider.class, method="updateByExample") |
||||
int updateByExample(@Param("record") HighDevice record, @Param("example") HighDeviceExample example); |
||||
|
||||
@UpdateProvider(type=HighDeviceSqlProvider.class, method="updateByPrimaryKeySelective") |
||||
int updateByPrimaryKeySelective(HighDevice record); |
||||
|
||||
@Update({ |
||||
"update high_device", |
||||
"set `type` = #{type,jdbcType=INTEGER},", |
||||
"company_id = #{companyId,jdbcType=BIGINT},", |
||||
"company_name = #{companyName,jdbcType=VARCHAR},", |
||||
"mer_id = #{merId,jdbcType=BIGINT},", |
||||
"mer_name = #{merName,jdbcType=VARCHAR},", |
||||
"mer_store_id = #{merStoreId,jdbcType=BIGINT},", |
||||
"mer_store_name = #{merStoreName,jdbcType=VARCHAR},", |
||||
"device_name = #{deviceName,jdbcType=VARCHAR},", |
||||
"device_sn = #{deviceSn,jdbcType=VARCHAR},", |
||||
"device_key = #{deviceKey,jdbcType=VARCHAR},", |
||||
"device_imei = #{deviceImei,jdbcType=VARCHAR},", |
||||
"device_iccid = #{deviceIccid,jdbcType=VARCHAR},", |
||||
"`status` = #{status,jdbcType=INTEGER},", |
||||
"create_time = #{createTime,jdbcType=TIMESTAMP},", |
||||
"update_time = #{updateTime,jdbcType=TIMESTAMP},", |
||||
"ext_1 = #{ext1,jdbcType=VARCHAR},", |
||||
"ext_2 = #{ext2,jdbcType=VARCHAR},", |
||||
"ext_3 = #{ext3,jdbcType=VARCHAR}", |
||||
"where id = #{id,jdbcType=BIGINT}" |
||||
}) |
||||
int updateByPrimaryKey(HighDevice record); |
||||
} |
@ -0,0 +1,7 @@ |
||||
package com.hai.dao; |
||||
|
||||
/** |
||||
* mapper扩展类 |
||||
*/ |
||||
public interface HighDeviceMapperExt { |
||||
} |
@ -0,0 +1,430 @@ |
||||
package com.hai.dao; |
||||
|
||||
import com.hai.entity.HighDevice; |
||||
import com.hai.entity.HighDeviceExample.Criteria; |
||||
import com.hai.entity.HighDeviceExample.Criterion; |
||||
import com.hai.entity.HighDeviceExample; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import org.apache.ibatis.jdbc.SQL; |
||||
|
||||
public class HighDeviceSqlProvider { |
||||
|
||||
public String countByExample(HighDeviceExample example) { |
||||
SQL sql = new SQL(); |
||||
sql.SELECT("count(*)").FROM("high_device"); |
||||
applyWhere(sql, example, false); |
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String deleteByExample(HighDeviceExample example) { |
||||
SQL sql = new SQL(); |
||||
sql.DELETE_FROM("high_device"); |
||||
applyWhere(sql, example, false); |
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String insertSelective(HighDevice record) { |
||||
SQL sql = new SQL(); |
||||
sql.INSERT_INTO("high_device"); |
||||
|
||||
if (record.getType() != null) { |
||||
sql.VALUES("`type`", "#{type,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getCompanyId() != null) { |
||||
sql.VALUES("company_id", "#{companyId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getCompanyName() != null) { |
||||
sql.VALUES("company_name", "#{companyName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getMerId() != null) { |
||||
sql.VALUES("mer_id", "#{merId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getMerName() != null) { |
||||
sql.VALUES("mer_name", "#{merName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getMerStoreId() != null) { |
||||
sql.VALUES("mer_store_id", "#{merStoreId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getMerStoreName() != null) { |
||||
sql.VALUES("mer_store_name", "#{merStoreName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getDeviceName() != null) { |
||||
sql.VALUES("device_name", "#{deviceName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getDeviceSn() != null) { |
||||
sql.VALUES("device_sn", "#{deviceSn,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getDeviceKey() != null) { |
||||
sql.VALUES("device_key", "#{deviceKey,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getDeviceImei() != null) { |
||||
sql.VALUES("device_imei", "#{deviceImei,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getDeviceIccid() != null) { |
||||
sql.VALUES("device_iccid", "#{deviceIccid,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getStatus() != null) { |
||||
sql.VALUES("`status`", "#{status,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getCreateTime() != null) { |
||||
sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getUpdateTime() != null) { |
||||
sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getExt1() != null) { |
||||
sql.VALUES("ext_1", "#{ext1,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt2() != null) { |
||||
sql.VALUES("ext_2", "#{ext2,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt3() != null) { |
||||
sql.VALUES("ext_3", "#{ext3,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String selectByExample(HighDeviceExample example) { |
||||
SQL sql = new SQL(); |
||||
if (example != null && example.isDistinct()) { |
||||
sql.SELECT_DISTINCT("id"); |
||||
} else { |
||||
sql.SELECT("id"); |
||||
} |
||||
sql.SELECT("`type`"); |
||||
sql.SELECT("company_id"); |
||||
sql.SELECT("company_name"); |
||||
sql.SELECT("mer_id"); |
||||
sql.SELECT("mer_name"); |
||||
sql.SELECT("mer_store_id"); |
||||
sql.SELECT("mer_store_name"); |
||||
sql.SELECT("device_name"); |
||||
sql.SELECT("device_sn"); |
||||
sql.SELECT("device_key"); |
||||
sql.SELECT("device_imei"); |
||||
sql.SELECT("device_iccid"); |
||||
sql.SELECT("`status`"); |
||||
sql.SELECT("create_time"); |
||||
sql.SELECT("update_time"); |
||||
sql.SELECT("ext_1"); |
||||
sql.SELECT("ext_2"); |
||||
sql.SELECT("ext_3"); |
||||
sql.FROM("high_device"); |
||||
applyWhere(sql, example, false); |
||||
|
||||
if (example != null && example.getOrderByClause() != null) { |
||||
sql.ORDER_BY(example.getOrderByClause()); |
||||
} |
||||
|
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String updateByExampleSelective(Map<String, Object> parameter) { |
||||
HighDevice record = (HighDevice) parameter.get("record"); |
||||
HighDeviceExample example = (HighDeviceExample) parameter.get("example"); |
||||
|
||||
SQL sql = new SQL(); |
||||
sql.UPDATE("high_device"); |
||||
|
||||
if (record.getId() != null) { |
||||
sql.SET("id = #{record.id,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getType() != null) { |
||||
sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getCompanyId() != null) { |
||||
sql.SET("company_id = #{record.companyId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getCompanyName() != null) { |
||||
sql.SET("company_name = #{record.companyName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getMerId() != null) { |
||||
sql.SET("mer_id = #{record.merId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getMerName() != null) { |
||||
sql.SET("mer_name = #{record.merName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getMerStoreId() != null) { |
||||
sql.SET("mer_store_id = #{record.merStoreId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getMerStoreName() != null) { |
||||
sql.SET("mer_store_name = #{record.merStoreName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getDeviceName() != null) { |
||||
sql.SET("device_name = #{record.deviceName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getDeviceSn() != null) { |
||||
sql.SET("device_sn = #{record.deviceSn,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getDeviceKey() != null) { |
||||
sql.SET("device_key = #{record.deviceKey,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getDeviceImei() != null) { |
||||
sql.SET("device_imei = #{record.deviceImei,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getDeviceIccid() != null) { |
||||
sql.SET("device_iccid = #{record.deviceIccid,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getStatus() != null) { |
||||
sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getCreateTime() != null) { |
||||
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getUpdateTime() != null) { |
||||
sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getExt1() != null) { |
||||
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt2() != null) { |
||||
sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt3() != null) { |
||||
sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
applyWhere(sql, example, true); |
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String updateByExample(Map<String, Object> parameter) { |
||||
SQL sql = new SQL(); |
||||
sql.UPDATE("high_device"); |
||||
|
||||
sql.SET("id = #{record.id,jdbcType=BIGINT}"); |
||||
sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); |
||||
sql.SET("company_id = #{record.companyId,jdbcType=BIGINT}"); |
||||
sql.SET("company_name = #{record.companyName,jdbcType=VARCHAR}"); |
||||
sql.SET("mer_id = #{record.merId,jdbcType=BIGINT}"); |
||||
sql.SET("mer_name = #{record.merName,jdbcType=VARCHAR}"); |
||||
sql.SET("mer_store_id = #{record.merStoreId,jdbcType=BIGINT}"); |
||||
sql.SET("mer_store_name = #{record.merStoreName,jdbcType=VARCHAR}"); |
||||
sql.SET("device_name = #{record.deviceName,jdbcType=VARCHAR}"); |
||||
sql.SET("device_sn = #{record.deviceSn,jdbcType=VARCHAR}"); |
||||
sql.SET("device_key = #{record.deviceKey,jdbcType=VARCHAR}"); |
||||
sql.SET("device_imei = #{record.deviceImei,jdbcType=VARCHAR}"); |
||||
sql.SET("device_iccid = #{record.deviceIccid,jdbcType=VARCHAR}"); |
||||
sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); |
||||
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); |
||||
sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); |
||||
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); |
||||
sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); |
||||
sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); |
||||
|
||||
HighDeviceExample example = (HighDeviceExample) parameter.get("example"); |
||||
applyWhere(sql, example, true); |
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String updateByPrimaryKeySelective(HighDevice record) { |
||||
SQL sql = new SQL(); |
||||
sql.UPDATE("high_device"); |
||||
|
||||
if (record.getType() != null) { |
||||
sql.SET("`type` = #{type,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getCompanyId() != null) { |
||||
sql.SET("company_id = #{companyId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getCompanyName() != null) { |
||||
sql.SET("company_name = #{companyName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getMerId() != null) { |
||||
sql.SET("mer_id = #{merId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getMerName() != null) { |
||||
sql.SET("mer_name = #{merName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getMerStoreId() != null) { |
||||
sql.SET("mer_store_id = #{merStoreId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getMerStoreName() != null) { |
||||
sql.SET("mer_store_name = #{merStoreName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getDeviceName() != null) { |
||||
sql.SET("device_name = #{deviceName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getDeviceSn() != null) { |
||||
sql.SET("device_sn = #{deviceSn,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getDeviceKey() != null) { |
||||
sql.SET("device_key = #{deviceKey,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getDeviceImei() != null) { |
||||
sql.SET("device_imei = #{deviceImei,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getDeviceIccid() != null) { |
||||
sql.SET("device_iccid = #{deviceIccid,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getStatus() != null) { |
||||
sql.SET("`status` = #{status,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getCreateTime() != null) { |
||||
sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getUpdateTime() != null) { |
||||
sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getExt1() != null) { |
||||
sql.SET("ext_1 = #{ext1,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt2() != null) { |
||||
sql.SET("ext_2 = #{ext2,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt3() != null) { |
||||
sql.SET("ext_3 = #{ext3,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
sql.WHERE("id = #{id,jdbcType=BIGINT}"); |
||||
|
||||
return sql.toString(); |
||||
} |
||||
|
||||
protected void applyWhere(SQL sql, HighDeviceExample example, boolean includeExamplePhrase) { |
||||
if (example == null) { |
||||
return; |
||||
} |
||||
|
||||
String parmPhrase1; |
||||
String parmPhrase1_th; |
||||
String parmPhrase2; |
||||
String parmPhrase2_th; |
||||
String parmPhrase3; |
||||
String parmPhrase3_th; |
||||
if (includeExamplePhrase) { |
||||
parmPhrase1 = "%s #{example.oredCriteria[%d].allCriteria[%d].value}"; |
||||
parmPhrase1_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; |
||||
parmPhrase2 = "%s #{example.oredCriteria[%d].allCriteria[%d].value} and #{example.oredCriteria[%d].criteria[%d].secondValue}"; |
||||
parmPhrase2_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{example.oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; |
||||
parmPhrase3 = "#{example.oredCriteria[%d].allCriteria[%d].value[%d]}"; |
||||
parmPhrase3_th = "#{example.oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; |
||||
} else { |
||||
parmPhrase1 = "%s #{oredCriteria[%d].allCriteria[%d].value}"; |
||||
parmPhrase1_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; |
||||
parmPhrase2 = "%s #{oredCriteria[%d].allCriteria[%d].value} and #{oredCriteria[%d].criteria[%d].secondValue}"; |
||||
parmPhrase2_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; |
||||
parmPhrase3 = "#{oredCriteria[%d].allCriteria[%d].value[%d]}"; |
||||
parmPhrase3_th = "#{oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; |
||||
} |
||||
|
||||
StringBuilder sb = new StringBuilder(); |
||||
List<Criteria> oredCriteria = example.getOredCriteria(); |
||||
boolean firstCriteria = true; |
||||
for (int i = 0; i < oredCriteria.size(); i++) { |
||||
Criteria criteria = oredCriteria.get(i); |
||||
if (criteria.isValid()) { |
||||
if (firstCriteria) { |
||||
firstCriteria = false; |
||||
} else { |
||||
sb.append(" or "); |
||||
} |
||||
|
||||
sb.append('('); |
||||
List<Criterion> criterions = criteria.getAllCriteria(); |
||||
boolean firstCriterion = true; |
||||
for (int j = 0; j < criterions.size(); j++) { |
||||
Criterion criterion = criterions.get(j); |
||||
if (firstCriterion) { |
||||
firstCriterion = false; |
||||
} else { |
||||
sb.append(" and "); |
||||
} |
||||
|
||||
if (criterion.isNoValue()) { |
||||
sb.append(criterion.getCondition()); |
||||
} else if (criterion.isSingleValue()) { |
||||
if (criterion.getTypeHandler() == null) { |
||||
sb.append(String.format(parmPhrase1, criterion.getCondition(), i, j)); |
||||
} else { |
||||
sb.append(String.format(parmPhrase1_th, criterion.getCondition(), i, j,criterion.getTypeHandler())); |
||||
} |
||||
} else if (criterion.isBetweenValue()) { |
||||
if (criterion.getTypeHandler() == null) { |
||||
sb.append(String.format(parmPhrase2, criterion.getCondition(), i, j, i, j)); |
||||
} else { |
||||
sb.append(String.format(parmPhrase2_th, criterion.getCondition(), i, j, criterion.getTypeHandler(), i, j, criterion.getTypeHandler())); |
||||
} |
||||
} else if (criterion.isListValue()) { |
||||
sb.append(criterion.getCondition()); |
||||
sb.append(" ("); |
||||
List<?> listItems = (List<?>) criterion.getValue(); |
||||
boolean comma = false; |
||||
for (int k = 0; k < listItems.size(); k++) { |
||||
if (comma) { |
||||
sb.append(", "); |
||||
} else { |
||||
comma = true; |
||||
} |
||||
if (criterion.getTypeHandler() == null) { |
||||
sb.append(String.format(parmPhrase3, i, j, k)); |
||||
} else { |
||||
sb.append(String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler())); |
||||
} |
||||
} |
||||
sb.append(')'); |
||||
} |
||||
} |
||||
sb.append(')'); |
||||
} |
||||
} |
||||
|
||||
if (sb.length() > 0) { |
||||
sql.WHERE(sb.toString()); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,344 @@ |
||||
package com.hai.entity; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* high_device |
||||
* @author |
||||
*/ |
||||
/** |
||||
* |
||||
* 代码由工具生成 |
||||
* |
||||
**/ |
||||
public class HighDevice implements Serializable { |
||||
/** |
||||
* 主键 |
||||
*/ |
||||
private Long id; |
||||
|
||||
/** |
||||
* 设备类型 1. 商鹏4G 2. 4G打印机 |
||||
*/ |
||||
private Integer type; |
||||
|
||||
/** |
||||
* 公司id |
||||
*/ |
||||
private Long companyId; |
||||
|
||||
/** |
||||
* 公司名称 |
||||
*/ |
||||
private String companyName; |
||||
|
||||
/** |
||||
* 商户id |
||||
*/ |
||||
private Long merId; |
||||
|
||||
/** |
||||
* 商户名称 |
||||
*/ |
||||
private String merName; |
||||
|
||||
/** |
||||
* 门店id |
||||
*/ |
||||
private Long merStoreId; |
||||
|
||||
/** |
||||
* 门店名称 |
||||
*/ |
||||
private String merStoreName; |
||||
|
||||
/** |
||||
* 设备名称 |
||||
*/ |
||||
private String deviceName; |
||||
|
||||
/** |
||||
* 设备SN编号 |
||||
*/ |
||||
private String deviceSn; |
||||
|
||||
/** |
||||
* 设备KEY编号 |
||||
*/ |
||||
private String deviceKey; |
||||
|
||||
/** |
||||
* 设备IMEI |
||||
*/ |
||||
private String deviceImei; |
||||
|
||||
/** |
||||
* 设备ICCID |
||||
*/ |
||||
private String deviceIccid; |
||||
|
||||
/** |
||||
* 状态:0:删除,1:正常 |
||||
*/ |
||||
private Integer status; |
||||
|
||||
/** |
||||
* 创建时间 |
||||
*/ |
||||
private Date createTime; |
||||
|
||||
/** |
||||
* 修改时间 |
||||
*/ |
||||
private Date updateTime; |
||||
|
||||
private String ext1; |
||||
|
||||
private String ext2; |
||||
|
||||
private String ext3; |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
public Long getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setId(Long id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
public Integer getType() { |
||||
return type; |
||||
} |
||||
|
||||
public void setType(Integer type) { |
||||
this.type = type; |
||||
} |
||||
|
||||
public Long getCompanyId() { |
||||
return companyId; |
||||
} |
||||
|
||||
public void setCompanyId(Long companyId) { |
||||
this.companyId = companyId; |
||||
} |
||||
|
||||
public String getCompanyName() { |
||||
return companyName; |
||||
} |
||||
|
||||
public void setCompanyName(String companyName) { |
||||
this.companyName = companyName; |
||||
} |
||||
|
||||
public Long getMerId() { |
||||
return merId; |
||||
} |
||||
|
||||
public void setMerId(Long merId) { |
||||
this.merId = merId; |
||||
} |
||||
|
||||
public String getMerName() { |
||||
return merName; |
||||
} |
||||
|
||||
public void setMerName(String merName) { |
||||
this.merName = merName; |
||||
} |
||||
|
||||
public Long getMerStoreId() { |
||||
return merStoreId; |
||||
} |
||||
|
||||
public void setMerStoreId(Long merStoreId) { |
||||
this.merStoreId = merStoreId; |
||||
} |
||||
|
||||
public String getMerStoreName() { |
||||
return merStoreName; |
||||
} |
||||
|
||||
public void setMerStoreName(String merStoreName) { |
||||
this.merStoreName = merStoreName; |
||||
} |
||||
|
||||
public String getDeviceName() { |
||||
return deviceName; |
||||
} |
||||
|
||||
public void setDeviceName(String deviceName) { |
||||
this.deviceName = deviceName; |
||||
} |
||||
|
||||
public String getDeviceSn() { |
||||
return deviceSn; |
||||
} |
||||
|
||||
public void setDeviceSn(String deviceSn) { |
||||
this.deviceSn = deviceSn; |
||||
} |
||||
|
||||
public String getDeviceKey() { |
||||
return deviceKey; |
||||
} |
||||
|
||||
public void setDeviceKey(String deviceKey) { |
||||
this.deviceKey = deviceKey; |
||||
} |
||||
|
||||
public String getDeviceImei() { |
||||
return deviceImei; |
||||
} |
||||
|
||||
public void setDeviceImei(String deviceImei) { |
||||
this.deviceImei = deviceImei; |
||||
} |
||||
|
||||
public String getDeviceIccid() { |
||||
return deviceIccid; |
||||
} |
||||
|
||||
public void setDeviceIccid(String deviceIccid) { |
||||
this.deviceIccid = deviceIccid; |
||||
} |
||||
|
||||
public Integer getStatus() { |
||||
return status; |
||||
} |
||||
|
||||
public void setStatus(Integer status) { |
||||
this.status = status; |
||||
} |
||||
|
||||
public Date getCreateTime() { |
||||
return createTime; |
||||
} |
||||
|
||||
public void setCreateTime(Date createTime) { |
||||
this.createTime = createTime; |
||||
} |
||||
|
||||
public Date getUpdateTime() { |
||||
return updateTime; |
||||
} |
||||
|
||||
public void setUpdateTime(Date updateTime) { |
||||
this.updateTime = updateTime; |
||||
} |
||||
|
||||
public String getExt1() { |
||||
return ext1; |
||||
} |
||||
|
||||
public void setExt1(String ext1) { |
||||
this.ext1 = ext1; |
||||
} |
||||
|
||||
public String getExt2() { |
||||
return ext2; |
||||
} |
||||
|
||||
public void setExt2(String ext2) { |
||||
this.ext2 = ext2; |
||||
} |
||||
|
||||
public String getExt3() { |
||||
return ext3; |
||||
} |
||||
|
||||
public void setExt3(String ext3) { |
||||
this.ext3 = ext3; |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object that) { |
||||
if (this == that) { |
||||
return true; |
||||
} |
||||
if (that == null) { |
||||
return false; |
||||
} |
||||
if (getClass() != that.getClass()) { |
||||
return false; |
||||
} |
||||
HighDevice other = (HighDevice) that; |
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) |
||||
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType())) |
||||
&& (this.getCompanyId() == null ? other.getCompanyId() == null : this.getCompanyId().equals(other.getCompanyId())) |
||||
&& (this.getCompanyName() == null ? other.getCompanyName() == null : this.getCompanyName().equals(other.getCompanyName())) |
||||
&& (this.getMerId() == null ? other.getMerId() == null : this.getMerId().equals(other.getMerId())) |
||||
&& (this.getMerName() == null ? other.getMerName() == null : this.getMerName().equals(other.getMerName())) |
||||
&& (this.getMerStoreId() == null ? other.getMerStoreId() == null : this.getMerStoreId().equals(other.getMerStoreId())) |
||||
&& (this.getMerStoreName() == null ? other.getMerStoreName() == null : this.getMerStoreName().equals(other.getMerStoreName())) |
||||
&& (this.getDeviceName() == null ? other.getDeviceName() == null : this.getDeviceName().equals(other.getDeviceName())) |
||||
&& (this.getDeviceSn() == null ? other.getDeviceSn() == null : this.getDeviceSn().equals(other.getDeviceSn())) |
||||
&& (this.getDeviceKey() == null ? other.getDeviceKey() == null : this.getDeviceKey().equals(other.getDeviceKey())) |
||||
&& (this.getDeviceImei() == null ? other.getDeviceImei() == null : this.getDeviceImei().equals(other.getDeviceImei())) |
||||
&& (this.getDeviceIccid() == null ? other.getDeviceIccid() == null : this.getDeviceIccid().equals(other.getDeviceIccid())) |
||||
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) |
||||
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) |
||||
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) |
||||
&& (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1())) |
||||
&& (this.getExt2() == null ? other.getExt2() == null : this.getExt2().equals(other.getExt2())) |
||||
&& (this.getExt3() == null ? other.getExt3() == null : this.getExt3().equals(other.getExt3())); |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
final int prime = 31; |
||||
int result = 1; |
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); |
||||
result = prime * result + ((getType() == null) ? 0 : getType().hashCode()); |
||||
result = prime * result + ((getCompanyId() == null) ? 0 : getCompanyId().hashCode()); |
||||
result = prime * result + ((getCompanyName() == null) ? 0 : getCompanyName().hashCode()); |
||||
result = prime * result + ((getMerId() == null) ? 0 : getMerId().hashCode()); |
||||
result = prime * result + ((getMerName() == null) ? 0 : getMerName().hashCode()); |
||||
result = prime * result + ((getMerStoreId() == null) ? 0 : getMerStoreId().hashCode()); |
||||
result = prime * result + ((getMerStoreName() == null) ? 0 : getMerStoreName().hashCode()); |
||||
result = prime * result + ((getDeviceName() == null) ? 0 : getDeviceName().hashCode()); |
||||
result = prime * result + ((getDeviceSn() == null) ? 0 : getDeviceSn().hashCode()); |
||||
result = prime * result + ((getDeviceKey() == null) ? 0 : getDeviceKey().hashCode()); |
||||
result = prime * result + ((getDeviceImei() == null) ? 0 : getDeviceImei().hashCode()); |
||||
result = prime * result + ((getDeviceIccid() == null) ? 0 : getDeviceIccid().hashCode()); |
||||
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); |
||||
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); |
||||
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); |
||||
result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode()); |
||||
result = prime * result + ((getExt2() == null) ? 0 : getExt2().hashCode()); |
||||
result = prime * result + ((getExt3() == null) ? 0 : getExt3().hashCode()); |
||||
return result; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
StringBuilder sb = new StringBuilder(); |
||||
sb.append(getClass().getSimpleName()); |
||||
sb.append(" ["); |
||||
sb.append("Hash = ").append(hashCode()); |
||||
sb.append(", id=").append(id); |
||||
sb.append(", type=").append(type); |
||||
sb.append(", companyId=").append(companyId); |
||||
sb.append(", companyName=").append(companyName); |
||||
sb.append(", merId=").append(merId); |
||||
sb.append(", merName=").append(merName); |
||||
sb.append(", merStoreId=").append(merStoreId); |
||||
sb.append(", merStoreName=").append(merStoreName); |
||||
sb.append(", deviceName=").append(deviceName); |
||||
sb.append(", deviceSn=").append(deviceSn); |
||||
sb.append(", deviceKey=").append(deviceKey); |
||||
sb.append(", deviceImei=").append(deviceImei); |
||||
sb.append(", deviceIccid=").append(deviceIccid); |
||||
sb.append(", status=").append(status); |
||||
sb.append(", createTime=").append(createTime); |
||||
sb.append(", updateTime=").append(updateTime); |
||||
sb.append(", ext1=").append(ext1); |
||||
sb.append(", ext2=").append(ext2); |
||||
sb.append(", ext3=").append(ext3); |
||||
sb.append(", serialVersionUID=").append(serialVersionUID); |
||||
sb.append("]"); |
||||
return sb.toString(); |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,44 @@ |
||||
package com.hai.enum_type; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
/** |
||||
* 设备类型 |
||||
* @author hurui |
||||
*/ |
||||
public enum DeviceTypeEnum { |
||||
type1(1 , "商鹏云打印"), |
||||
type2(2, "ZKC云打印"), |
||||
; |
||||
|
||||
private Integer type; |
||||
private String name; |
||||
|
||||
DeviceTypeEnum(int type , String name) { |
||||
this.type = type; |
||||
this.name = name; |
||||
} |
||||
|
||||
public static String getNameByType(Integer type) { |
||||
for (DeviceTypeEnum ele : values()) { |
||||
if(Objects.equals(type,ele.getType())) return ele.getName(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public Integer getType() { |
||||
return type; |
||||
} |
||||
|
||||
public void setType(Integer type) { |
||||
this.type = type; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
} |
@ -0,0 +1,42 @@ |
||||
package com.hai.service; |
||||
|
||||
import com.hai.entity.HighDevice; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 设备管理 |
||||
* @author hurui |
||||
*/ |
||||
public interface HighDeviceService { |
||||
|
||||
/** |
||||
* 编辑设备 |
||||
* @param device |
||||
*/ |
||||
void editDevice(HighDevice device); |
||||
|
||||
/** |
||||
* 查询设备详情 |
||||
* @param deviceId |
||||
* @return |
||||
*/ |
||||
HighDevice getDetailById(Long deviceId); |
||||
|
||||
/** |
||||
* 查询设备列表 |
||||
* @param param |
||||
* @return |
||||
*/ |
||||
List<HighDevice> getDeviceList(Map<String, Object> param); |
||||
|
||||
/** |
||||
* 根据门店id,查询设备列表 |
||||
* @param storeId |
||||
* @return |
||||
*/ |
||||
List<HighDevice> getDeviceListByStoreId(Long storeId); |
||||
|
||||
|
||||
} |
@ -0,0 +1,77 @@ |
||||
package com.hai.service.impl; |
||||
|
||||
import com.hai.dao.HighDeviceMapper; |
||||
import com.hai.entity.HighDevice; |
||||
import com.hai.entity.HighDeviceExample; |
||||
import com.hai.service.HighDeviceService; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service("deviceService") |
||||
public class HighDeviceServiceImpl implements HighDeviceService { |
||||
|
||||
@Resource |
||||
private HighDeviceMapper deviceMapper; |
||||
|
||||
@Override |
||||
public void editDevice(HighDevice device) { |
||||
if (device.getId() == null) { |
||||
device.setCreateTime(new Date()); |
||||
device.setUpdateTime(new Date()); |
||||
device.setStatus(1); |
||||
deviceMapper.insert(device); |
||||
} else { |
||||
device.setUpdateTime(new Date()); |
||||
deviceMapper.updateByPrimaryKey(device); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public HighDevice getDetailById(Long deviceId) { |
||||
return deviceMapper.selectByPrimaryKey(deviceId); |
||||
} |
||||
|
||||
@Override |
||||
public List<HighDevice> getDeviceList(Map<String, Object> param) { |
||||
HighDeviceExample example = new HighDeviceExample(); |
||||
HighDeviceExample.Criteria criteria = example.createCriteria().andStatusNotEqualTo(0); |
||||
|
||||
if (MapUtils.getInteger(param, "type") != null) { |
||||
criteria.andTypeEqualTo(MapUtils.getInteger(param, "type")); |
||||
} |
||||
|
||||
if (MapUtils.getLong(param, "companyId") != null) { |
||||
criteria.andCompanyIdEqualTo(MapUtils.getLong(param, "companyId")); |
||||
} |
||||
|
||||
if (MapUtils.getLong(param, "merId") != null) { |
||||
criteria.andMerIdEqualTo(MapUtils.getLong(param, "merId")); |
||||
} |
||||
|
||||
if (MapUtils.getLong(param, "storeId") != null) { |
||||
criteria.andMerStoreIdEqualTo(MapUtils.getLong(param, "storeId")); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(MapUtils.getString(param, "deviceName"))) { |
||||
criteria.andDeviceNameLike("%" + MapUtils.getString(param, "deviceName") + "%"); |
||||
} |
||||
|
||||
example.setOrderByClause("create_time desc"); |
||||
return deviceMapper.selectByExample(example); |
||||
} |
||||
|
||||
@Override |
||||
public List<HighDevice> getDeviceListByStoreId(Long storeId) { |
||||
HighDeviceExample example = new HighDeviceExample(); |
||||
example.createCriteria() |
||||
.andMerStoreIdEqualTo(storeId) |
||||
.andStatusNotEqualTo(0); |
||||
return deviceMapper.selectByExample(example); |
||||
} |
||||
} |
Loading…
Reference in new issue