车车 8 kuukautta sitten
vanhempi
sitoutus
8e3b351c4c

+ 2 - 1
ktg-admin/src/main/java/com/ktg/web/controller/system/SysUserCharacteristicController.java

@@ -97,7 +97,8 @@ public class SysUserCharacteristicController extends BaseController
         if (one != null) {
             sysAttrValue = one.getSysAttrValue();
         }
-        return CommonResult.success(sysUserCharacteristicService.insertUserFingerprintDat(file, userName, sysAttrValue));
+        String url = serverConfig.getUrl();
+        return CommonResult.success(sysUserCharacteristicService.insertUserFingerprintDat(file, userName, sysAttrValue, url));
     }
 
     @ApiOperation("修改用户特征(指纹、面部)")

+ 4 - 0
ktg-system/src/main/java/com/ktg/system/domain/SysUserCharacteristic.java

@@ -40,6 +40,10 @@ public class SysUserCharacteristic extends BaseBean
     @Excel(name = "图片地址")
     private String imageUrl;
 
+    @ApiModelProperty(value = "图片路径")
+    @Excel(name = "图片路径")
+    private String imagePath;
+
     @ApiModelProperty(value = "排序")
     @Excel(name = "排序")
     private Integer orderNum;

+ 1 - 1
ktg-system/src/main/java/com/ktg/system/service/ISysUserCharacteristicService.java

@@ -18,7 +18,7 @@ public interface ISysUserCharacteristicService extends IService<SysUserCharacter
 
     Page<SysUserCharacteristic> getSysUserCharacteristicPage(Page<SysUserCharacteristic> page, SysUserCharacteristic sysUserCharacteristic, String url);
 
-    Boolean insertUserFingerprintDat(MultipartFile file, String userName, String sysAttrValue) throws IOException;
+    Boolean insertUserFingerprintDat(MultipartFile file, String userName, String sysAttrValue, String url) throws IOException;
 
     Boolean deleteSysUserCharacteristicByRecordIds(String recordIds);
 

+ 13 - 4
ktg-system/src/main/java/com/ktg/system/service/impl/SysUserCharacteristicServiceImpl.java

@@ -63,7 +63,7 @@ public class SysUserCharacteristicServiceImpl extends ServiceImpl<SysUserCharact
     }
 
     @Override
-    public Boolean insertUserFingerprintDat(MultipartFile file, String userName, String sysAttrValue) throws IOException {
+    public Boolean insertUserFingerprintDat(MultipartFile file, String userName, String sysAttrValue, String url) throws IOException {
         Assert.notBlank(userName, "请告知我这是哪个用户的指纹!");
         Assert.isTrue(file.getSize() > 0, "指纹信息不能为空!");
         SysUser user = iSysUserService.getOne(Wrappers.<SysUser>lambdaQuery()
@@ -99,6 +99,7 @@ public class SysUserCharacteristicServiceImpl extends ServiceImpl<SysUserCharact
 
         // 开始生成dat文件
         String imagePath = null;
+        String imageUrl = null;
         try {
             imagePath = filePath + fileName; // 替换为你的指纹图片路径
             byte[] fingerprintData = extractFingerprintTemplate(imagePath);
@@ -106,6 +107,13 @@ public class SysUserCharacteristicServiceImpl extends ServiceImpl<SysUserCharact
             // 保存到文件
             Files.write(Paths.get(filePath + userId + "_" + currentTimestamp + ".dat"), fingerprintData);
             System.out.println("指纹特征值已保存!");
+            // 图片地址
+            String profile = RuoYiConfig.getProfile();
+            if (imagePath.contains("C:" + profile)) {
+                imageUrl = imagePath.replace("C:" + profile, url + "/profile");
+            } else if (imagePath.contains(profile)) {
+                imageUrl = imagePath.replace(profile, url + "/prod-api" + "/profile");
+            }
         } catch (IOException e) {
             e.printStackTrace();
         }
@@ -114,7 +122,8 @@ public class SysUserCharacteristicServiceImpl extends ServiceImpl<SysUserCharact
         sysUserCharacteristic.setType("1");
         sysUserCharacteristic.setContent(filePath + userId + "_" + currentTimestamp + ".dat");
         sysUserCharacteristic.setOrderNum(0);
-        sysUserCharacteristic.setImageUrl(imagePath);
+        sysUserCharacteristic.setImageUrl(imageUrl);
+        sysUserCharacteristic.setImagePath(imagePath);
         save(sysUserCharacteristic);
         return true;
     }
@@ -144,9 +153,9 @@ public class SysUserCharacteristicServiceImpl extends ServiceImpl<SysUserCharact
                 if (!file.delete()) {
                     log.error("DAT文件删除失败: " + sysUserCharacteristic.getContent());
                 }
-                File file1 = new File(sysUserCharacteristic.getImageUrl());
+                File file1 = new File(sysUserCharacteristic.getImagePath());
                 if (!file1.delete()) {
-                    log.error("img文件删除失败: " + sysUserCharacteristic.getImageUrl());
+                    log.error("img文件删除失败: " + sysUserCharacteristic.getImagePath());
                 }
             }
         }