|
|
@@ -375,7 +375,7 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
|
|
|
String filePath = rootPath + path;
|
|
|
String codePath = path + model.getId() + ".png";
|
|
|
model.setQrCode(codePath);
|
|
|
- CodeFileUtils.uploadFileECode(model.getId(), rootPath, filePath, model.getId() + ".png");
|
|
|
+ CodeFileUtils.uploadFileECode(buildSbQrCodeUrl(model.getId()), rootPath, filePath, model.getId() + ".png");
|
|
|
// 保存文件
|
|
|
this.saveImageFile(model);
|
|
|
this.saveUseFile(model);
|
|
|
@@ -427,7 +427,7 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
|
|
|
String filePath = rootPath + path;
|
|
|
String codePath = path + model.getId() + ".png";
|
|
|
model.setQrCode(codePath);
|
|
|
- CodeFileUtils.uploadFileECode(model.getId(), rootPath, filePath, model.getId() + ".png");
|
|
|
+ CodeFileUtils.uploadFileECode(buildSbQrCodeUrl(model.getId()), rootPath, filePath, model.getId() + ".png");
|
|
|
|
|
|
// 2:复制部位
|
|
|
PartInfoDTO partInfoDTO = new PartInfoDTO();
|
|
|
@@ -1565,7 +1565,7 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
|
|
|
String rootPath = environment.getProperty("upload.root-dir");
|
|
|
String filePath = rootPath + path;
|
|
|
String codePath = path + vo.getId() + ".png";
|
|
|
- CodeFileUtils.uploadFileECode(vo.getId(), rootPath, filePath, vo.getId() + ".png");
|
|
|
+ CodeFileUtils.uploadFileECode(buildSbQrCodeUrl(vo.getId()), rootPath, filePath, vo.getId() + ".png");
|
|
|
// 修改二维码
|
|
|
SbInfoDTO sbInfoDTO = new SbInfoDTO();
|
|
|
sbInfoDTO.setId(vo.getId());
|
|
|
@@ -1611,29 +1611,15 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
|
|
|
public void generateSbCodeAll() {
|
|
|
List<SbInfo> list = mapper.selectAll();
|
|
|
|
|
|
- String domain = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SYSTEM_DOMAIN_MOBILE.name());
|
|
|
- String sbUrl = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SYSTEM_SB_URL.name());
|
|
|
- if (StringUtils.isBlank(domain)) {
|
|
|
- throw new BusinessException("请先设置系统域名地址,系统管理-》系统参数配置-》SYSTEM_DOMAIN");
|
|
|
- }
|
|
|
- if (!domain.endsWith("/")) {
|
|
|
- domain = domain + "/";
|
|
|
- }
|
|
|
- if (StringUtils.isBlank(sbUrl)) {
|
|
|
- throw new BusinessException("请先设置设备跳转前缀地址,系统管理-》系统参数配置-》SYSTEM_DOMAIN_MOBILE");
|
|
|
- }
|
|
|
- if (!sbUrl.endsWith("/") && !sbUrl.endsWith("=")) {
|
|
|
- sbUrl = sbUrl + "/";
|
|
|
- }
|
|
|
if (CollectionUtil.isNotEmpty(list)) {
|
|
|
+ String rootPath = environment.getProperty("upload.root-dir");
|
|
|
// 保存二维码
|
|
|
for (SbInfo sbInfo : list) {
|
|
|
String path = CommonConstants.RESOURCE_PREFIX + "/png/" + DateUtil.formatDate(new Date()) + "/"
|
|
|
+ IdGeneratorUtils.getObjectId() + "/";
|
|
|
- String rootPath = environment.getProperty("upload.root-dir");
|
|
|
String filePath = rootPath + path;
|
|
|
String codePath = path + sbInfo.getId() + ".png";
|
|
|
- CodeFileUtils.uploadFileECode(domain + sbUrl + sbInfo.getId(), rootPath, filePath,
|
|
|
+ CodeFileUtils.uploadFileECode(buildSbQrCodeUrl(sbInfo.getId()), rootPath, filePath,
|
|
|
sbInfo.getId() + ".png");
|
|
|
// 修改
|
|
|
sbInfo.setQrCode(codePath);
|
|
|
@@ -1642,6 +1628,30 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 构建设备二维码URL:domain + sbUrl + id
|
|
|
+ *
|
|
|
+ * @param id 设备ID
|
|
|
+ * @return 完整的移动端跳转URL
|
|
|
+ */
|
|
|
+ private String buildSbQrCodeUrl(String id) {
|
|
|
+ String domain = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SYSTEM_DOMAIN_MOBILE.name());
|
|
|
+ String sbUrl = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SYSTEM_SB_URL.name());
|
|
|
+ if (StringUtils.isBlank(domain)) {
|
|
|
+ throw new BusinessException("请先设置系统域名地址,系统管理-》系统参数配置-》SYSTEM_DOMAIN_MOBILE");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(sbUrl)) {
|
|
|
+ throw new BusinessException("请先设置设备跳转前缀地址,系统管理-》系统参数配置-》SYSTEM_SB_URL");
|
|
|
+ }
|
|
|
+ if (!domain.endsWith("/")) {
|
|
|
+ domain = domain + "/";
|
|
|
+ }
|
|
|
+ if (!sbUrl.endsWith("/") && !sbUrl.endsWith("=")) {
|
|
|
+ sbUrl = sbUrl + "/";
|
|
|
+ }
|
|
|
+ return domain + sbUrl + id;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String importListByAdd(MultipartFile file) {
|
|
|
@@ -1792,6 +1802,20 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
|
|
|
if (!CollectionUtils.isEmpty(addItems)) {
|
|
|
List<SbInfo> itemsAdd = BeanConverterUtil.copyListProperties(addItems, SbInfo.class);
|
|
|
mapper.insertListforComplex(itemsAdd);
|
|
|
+
|
|
|
+ // 为每个新导入的设备生成二维码
|
|
|
+ String rootPath = environment.getProperty("upload.root-dir");
|
|
|
+ for (SbInfo sbInfo : itemsAdd) {
|
|
|
+ // 保存二维码
|
|
|
+ String path = CommonConstants.RESOURCE_PREFIX + "/png/" + DateUtil.formatDate(new Date()) + "/"
|
|
|
+ + IdGeneratorUtils.getObjectId() + "/";
|
|
|
+ String filePath = rootPath + path;
|
|
|
+ String codePath = path + sbInfo.getId() + ".png";
|
|
|
+ sbInfo.setQrCode(codePath);
|
|
|
+ CodeFileUtils.uploadFileECode(buildSbQrCodeUrl(sbInfo.getId()), rootPath, filePath, sbInfo.getId() + ".png");
|
|
|
+ // 更新二维码路径到数据库
|
|
|
+ mapper.updateByPrimaryKeySelective(sbInfo);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return "总计新增导入:" + (items.size());
|
|
|
@@ -2031,6 +2055,18 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
|
|
|
singleList.add(toSave.get(idx));
|
|
|
mapper.insertListforComplex(singleList);
|
|
|
newCount++;
|
|
|
+
|
|
|
+ // 为新增的设备生成二维码
|
|
|
+ SbInfo sbInfo = toSave.get(idx);
|
|
|
+ String rootPath = environment.getProperty("upload.root-dir");
|
|
|
+ String path = CommonConstants.RESOURCE_PREFIX + "/png/" + DateUtil.formatDate(new Date()) + "/"
|
|
|
+ + IdGeneratorUtils.getObjectId() + "/";
|
|
|
+ String filePath = rootPath + path;
|
|
|
+ String codePath = path + sbInfo.getId() + ".png";
|
|
|
+ sbInfo.setQrCode(codePath);
|
|
|
+ CodeFileUtils.uploadFileECode(buildSbQrCodeUrl(sbInfo.getId()), rootPath, filePath, sbInfo.getId() + ".png");
|
|
|
+ // 更新二维码路径到数据库
|
|
|
+ mapper.updateByPrimaryKeySelective(sbInfo);
|
|
|
} else {
|
|
|
mapper.updateByPrimaryKeySelective(toSave.get(idx));
|
|
|
}
|