Parcourir la source

归档和签名删上传问题

xiaochan il y a 3 mois
Parent
commit
4faa8d0080

+ 0 - 6
src/main/java/thyyxxk/webserver/controller/settings/SettingsController.java

@@ -144,12 +144,6 @@ public class SettingsController {
         return service.resetPasswordByCode(r.getCode(), r.getNextTime());
     }
 
-    @PassToken
-    @PostMapping("/setAutographImage")
-    public ResultVo<Map<String, Object>> setAutographImage(@RequestBody MultipartFile file, @RequestParam("code") String code) {
-        return service.setAutographImage(file, code);
-    }
-
     @GetMapping("/selectAutographImageByCode")
     public ResultVo<Map<String, Object>> selectAutographImageByCode(@RequestParam("code") String code) {
         return service.selectAutographImageByCode(code);

+ 6 - 0
src/main/java/thyyxxk/webserver/dao/his/settings/SettingsDao.java

@@ -219,6 +219,9 @@ public interface SettingsDao {
     @Update(" update a_employee_image set autograph_image = #{img} where code = #{code} ")
     int updateAutographImage(@Param("code") String code, @Param("img") String img);
 
+    @Select("select autograph_image from  a_employee_image where code = #{code}  ")
+    String getAutographImage(@Param("code") String code);
+
     @Insert(" insert into a_employee_image(code, image_comment, comment_type, image_base64, sex, autograph_image) " +
             " values (#{code}, null, '2', null, #{sex}, #{img}) ")
     int intoAutographImage(@Param("code") String code, @Param("img") String img, @Param("sex") String sex);
@@ -236,4 +239,7 @@ public interface SettingsDao {
     void updateUserConfig(@Param("config") String config,
                           @Param("userCode") String userCode);
 
+
+
+
 }

+ 44 - 0
src/main/java/thyyxxk/webserver/service/archive/ArchiveServer.java

@@ -294,5 +294,49 @@ public class ArchiveServer {
         return uploadFileByBytes(data, path, !isProd, null);
     }
 
+
+    /**
+     * 创建文件
+     *
+     * @param file 文件
+     * @param path 地址用 /开头
+     * @return 返回你传入的地址,如果你是工作集成平台的话可以指定用这个地址访问到
+     */
+    public String createFile(MultipartFile file, String path) {
+        JSONObject execute;
+        try {
+            execute = sendApi("/createFile").contentFormUrlEncoded()
+                    .addHeader("content-type", "multipart/form-data")
+                    .addFile("file", file.getInputStream(), file.getOriginalFilename(), file.getContentType())
+                    .addBody("path", path)
+                    .execute(JSONObject.class);
+            ;
+        } catch (Exception e) {
+            throw new BizException(ExceptionEnum.LOGICAL_ERROR, "上传文件错误:" + e.getMessage());
+        }
+        Integer code = execute.getInteger("code");
+
+        if (ExceptionEnum.SUCCESS.getCode() != code) {
+            throw new BizException(ExceptionEnum.LOGICAL_ERROR, "上传文件错误:" + execute.getString("message"));
+        }
+
+        return execute.getObject("data", String.class);
+    }
+
+
+    public String deleteFile(String path) {
+        Map<String, String> map = new HashMap<>();
+        map.put("path", path);
+        JSONObject execute = sendApi("/deleteFile")
+                .addBody(map)
+                .execute(JSONObject.class);
+
+        Integer code = execute.getInteger("code");
+        if (ExceptionEnum.SUCCESS.getCode() != code) {
+            throw new BizException(ExceptionEnum.LOGICAL_ERROR, execute.getString("message"));
+        }
+        return execute.getObject("data", String.class);
+    }
+
 }
 

+ 8 - 65
src/main/java/thyyxxk/webserver/service/settings/SettingsService.java

@@ -1,6 +1,7 @@
 package thyyxxk.webserver.service.settings;
 
 import cn.hutool.core.io.file.FileNameUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.hutool.crypto.SecureUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
@@ -30,6 +31,7 @@ import thyyxxk.webserver.http.websocket.dto.WebSocketByListUserCode;
 import thyyxxk.webserver.http.websocket.dto.WebSocketByUserCode;
 import thyyxxk.webserver.service.PublicServer;
 import thyyxxk.webserver.service.TokenService;
+import thyyxxk.webserver.service.archive.ArchiveServer;
 import thyyxxk.webserver.service.externalhttp.CorpWxSrvc;
 import thyyxxk.webserver.service.hutoolcache.CacheEnums;
 import thyyxxk.webserver.service.hutoolcache.ExtraCache;
@@ -58,9 +60,8 @@ public class SettingsService {
     private final SystemConfig systemConfig;
     private final TokenService tokenService;
     private final SocketV2 intergrationPlatformSocket;
+    private final ArchiveServer archiveServer;
 
-    @Value("${is-prod}")
-    private boolean isProd;
 
     public ResultVo<UserInfo> getUserInfo() {
         final String code = TokenUtil.getInstance().getTokenUserId();
@@ -299,39 +300,6 @@ public class SettingsService {
         return dao.selectAllUsers(page, qw).getRecords().get(0);
     }
 
-    /**
-     * @param file 签名  code 人员编码
-     * @return map
-     * @Description 更新医生的签名
-     * @Author hsh
-     * @Date 2024/5/14 10:36
-     */
-    public ResultVo<Map<String, Object>> setAutographImage(MultipartFile file, String code) {
-        if (StringUtil.isBlank(code)) {
-            return ResultVoUtil.fail(ExceptionEnum.INVALID_PARAM);
-        }
-        String img = base64Encode(file);
-        Map<String, Object> m = dao.selectAutographImageByCode(code);
-        int count;
-        if (null == m || m.isEmpty()) {
-            EmployeeMi mi = dao.selectEmployeeMiByCode(code);
-            if (null != mi) {
-                count = dao.intoAutographImage(code, img, mi.getSexCode() == null ? "9" : mi.getSexCode());
-            } else {
-                count = dao.intoAutographImage(code, img, "9");
-            }
-        } else {
-            count = dao.updateAutographImage(code, img);
-        }
-        if (count > 0) {
-            Map<String, Object> map = new HashMap<>();
-            Map<String, Object> imgMap = dao.selectAutographImageByCode(code);
-            map.put("data", imgMap);
-            return ResultVoUtil.success(map);
-        } else {
-            return ResultVoUtil.fail(ExceptionEnum.NEED_PROOFREAD);
-        }
-    }
 
     /**
      * @param code 医生编码
@@ -344,19 +312,6 @@ public class SettingsService {
         return ResultVoUtil.success(dao.selectAutographImageByCode(code));
     }
 
-    private String base64Encode(MultipartFile file) {
-        String ret = null;
-        if (file == null) {
-            return null;
-        }
-        try {
-            Base64.Encoder encoder = Base64.getEncoder();
-            ret = encoder.encodeToString(file.getBytes());
-        } catch (Exception e) {
-            log.error("将图片文件转base64出错", e);
-        }
-        return ret;
-    }
 
     public ResultVo<JSONObject> putAutographImage(MultipartFile file, String code) {
         String codeRs = "";
@@ -370,26 +325,14 @@ public class SettingsService {
             }
         }
 
-        String uploadDir = systemConfig.getDoctorSignFolder();
-
+        String createFilePath = StrUtil.format("/{}/doctorSignature/{}.png", "archive", code);
+        archiveServer.createFile(file, createFilePath);
         JSONObject js = new JSONObject();
-
         String name = FileNameUtil.extName(file.getOriginalFilename());
         String fileName = code + "." + name;
-        Path uploadPath = Paths.get(uploadDir);
-        try {
-            Files.createDirectories(uploadPath);
-            Path filePath = uploadPath.resolve(fileName);
-            Files.copy(file.getInputStream(), filePath, StandardCopyOption.REPLACE_EXISTING);
-            log.info("文件:{}, code:{}", file.getName(), code);
-            String url = "/doctorSignatureImage/" + fileName;
-            js.put("url", url);
-            js.put("name", fileName);
-            return ResultVoUtil.success(js);
-        } catch (IOException e) {
-            log.error("上传错误:{}", e.getMessage());
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "上传错误请重新上传。");
-        }
+        js.put("url", StrUtil.format("/doctorSignatureImage/{}.png", "archive", code));
+        js.put("name", fileName);
+        return ResultVoUtil.success(js);
     }
 
     public void setUserConfig(String js) {

+ 6 - 1
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/ShouShuShenQingService.java

@@ -17,6 +17,7 @@ import thyyxxk.webserver.entity.dictionary.CodeName;
 import thyyxxk.webserver.entity.zhuyuanyisheng.query.ChaXunJianChaHeJianYan;
 import thyyxxk.webserver.entity.zhuyuanyisheng.shoushu.*;
 import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.XinZhenYiZhu;
+import thyyxxk.webserver.http.websocket.SocketV2;
 import thyyxxk.webserver.service.PublicServer;
 import thyyxxk.webserver.utils.*;
 
@@ -36,11 +37,13 @@ public class ShouShuShenQingService {
     private final ShouShuShenQingDao dao;
     private final PublicServer publicServer;
     private final YiZhuLuRuDao yiZhuLuRuDao;
+    private final SocketV2 socketV2;
 
-    public ShouShuShenQingService(ShouShuShenQingDao dao, PublicServer publicServer, YiZhuLuRuDao yiZhuLuRuDao) {
+    public ShouShuShenQingService(ShouShuShenQingDao dao, PublicServer publicServer, YiZhuLuRuDao yiZhuLuRuDao, SocketV2 socketV2) {
         this.dao = dao;
         this.publicServer = publicServer;
         this.yiZhuLuRuDao = yiZhuLuRuDao;
+        this.socketV2 = socketV2;
     }
 
     /**
@@ -191,6 +194,8 @@ public class ShouShuShenQingService {
         String msgContent = String.format("手术名称:<span style='color:#409eff'>【%s】</span><br>" +
                 "手术时间:<span style='color:#409eff'>【%tF %<tT】</span><br>", op.getOpName(), op.getOpDatetime());
 
+//        socketV2.sendMessageByUserCode();
+
         XinZhenYiZhu patInfo = yiZhuLuRuDao.queryPatientInfo(ss.getInpatientNo(), ss.getAdmissTimes());
         String yzCode = ss.getGenerateRejectedOrders() ? "06054" : "10399";
 

+ 1 - 1
src/main/resources/application-prod.yml

@@ -155,7 +155,7 @@ thyy:
     doctor-sign-folder: "/home/doctorSignature"
   archive:
     path: "/mnt/archive"
-    archive-url: http://172.16.32.167:20921/thyy/api/archive
+    archive-url: http://172.16.32.197:20921/thyy/api/archive
   apiurl:
     socket-api: http://172.16.32.160:20922/thyy/api/socket
     scheduled-api: http://localhost:21702/thyy/scheduled/api