we200升级数据包接口

master
382696293@qq.com 2 years ago
parent 8544a48f99
commit 086bd1c44e

@ -144,8 +144,8 @@ public class WxInstrumentController extends BaseController {
* 1 * 1
*/ */
@GetMapping(value = "/upgrade") @GetMapping(value = "/upgrade")
public R upgrade(@RequestParam("instrumentId") Long instrumentId) { public R upgrade(@RequestParam("instrumentId") Long instrumentId, @RequestParam(value = "isWe200") Boolean isWe200) {
return R.ok(wxInstrumentService.upgrade(instrumentId)); return R.ok(wxInstrumentService.upgrade(instrumentId, isWe200));
} }
/** /**

@ -29,7 +29,7 @@ public interface IWxInstrumentService {
WxInstrumentSerial determineSerialIsSameInstrument(String serial, Long instrumentId); WxInstrumentSerial determineSerialIsSameInstrument(String serial, Long instrumentId);
String upgrade(Long instrumentId); String upgrade(Long instrumentId, Boolean isWe200);
WxBindingInstrumentInfo bindingInstrumentInfo(Long instrumentId); WxBindingInstrumentInfo bindingInstrumentInfo(Long instrumentId);
} }

@ -431,12 +431,17 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
} }
@Override @Override
public String upgrade(Long instrumentId) { public String upgrade(Long instrumentId, Boolean isWe200) {
WxInstrument wxInstrument = wxInstrumentMapper.selectWxInstrumentById(instrumentId); WxInstrument wxInstrument = wxInstrumentMapper.selectWxInstrumentById(instrumentId);
if (wxInstrument != null && StringUtils.isNotBlank(wxInstrument.getIotUpgradeData())) { if (wxInstrument != null && StringUtils.isNotBlank(wxInstrument.getIotUpgradeData())) {
// 读取文件系统中的文件 // 读取文件系统中的文件
try { try {
byte[] byteArray = FileCopyUtils.copyToByteArray(new URL(wxInstrument.getIotUpgradeData()).openStream()); byte[] byteArray;
if (isWe200) {
byteArray = FileCopyUtils.copyToByteArray(new URL(wxInstrument.getWe200IotUpgradeData()).openStream());
} else {
byteArray = FileCopyUtils.copyToByteArray(new URL(wxInstrument.getIotUpgradeData()).openStream());
}
return DatatypeConverter.printHexBinary(byteArray); return DatatypeConverter.printHexBinary(byteArray);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
logger.error("instrumentId:{} 升级失败: {}", instrumentId, e.getMessage()); logger.error("instrumentId:{} 升级失败: {}", instrumentId, e.getMessage());

Loading…
Cancel
Save