tjf 4 месяцев назад
Родитель
Сommit
9b237d9c5f

+ 3 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java

@@ -87,7 +87,10 @@ public class CommonController
             String fileName = FileUploadUtils.upload(filePath, file);
             String url = serverConfig.getUrl() + fileName;
             AjaxResult ajax = AjaxResult.success();
+            //服务器路径
+            String urlOnline = filePath + fileName.replace("/profile/upload", "");
             ajax.put("url", url);
+            ajax.put("urlOnline", urlOnline);
             ajax.put("fileName", fileName);
             ajax.put("newFileName", FileUtils.getName(fileName));
             ajax.put("originalFilename", file.getOriginalFilename());

+ 24 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/OcrController.java

@@ -42,4 +42,28 @@ public class OcrController {
     public AjaxResult ocrBusinessLicense(@RequestBody IdCardVo idCardVo) {
         return IdCardUtil.businessLicense(idCardVo.getImage());
     }
+
+    /**
+     * 车牌照识别
+     *
+     * @return
+     */
+    @PostMapping("/licensePlate")
+    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
+    @PreAuthorize("@ss.hasPermi('wuYe:ocr:licensePlate')")
+    public AjaxResult licensePlate(@RequestBody IdCardVo idCardVo) {
+        return IdCardUtil.licensePlate(idCardVo.getImage());
+    }
+
+    /**
+     * 房产证识别
+     *
+     * @return
+     */
+    @PostMapping("/realEstateCertificate")
+    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
+    @PreAuthorize("@ss.hasPermi('wuYe:ocr:realEstateCertificate')")
+    public AjaxResult realEstateCertificate(@RequestBody IdCardVo idCardVo) {
+        return IdCardUtil.realEstateCertificate(idCardVo.getImage());
+    }
 }

+ 13 - 19
ruoyi-admin/src/main/java/com/ruoyi/web/controller/reservRecord/ReservRecordController.java

@@ -11,6 +11,7 @@ import com.ruoyi.system.service.IReservRecordService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
+
 import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
@@ -22,18 +23,16 @@ import java.util.List;
  */
 @RestController
 @RequestMapping("/wuYe/reservRecord")
-public class ReservRecordController extends BaseController
-{
+public class ReservRecordController extends BaseController {
     @Autowired
     private IReservRecordService reservRecordService;
 
-/**
- * 查询预约记录列表
- */
-@PreAuthorize("@ss.hasPermi('wuYe:reservRecord:list')")
-@GetMapping("/list")
-    public TableDataInfo list(ReservRecord reservRecord)
-    {
+    /**
+     * 查询预约记录列表
+     */
+    @PreAuthorize("@ss.hasPermi('wuYe:reservRecord:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(ReservRecord reservRecord) {
         startPage();
         List<ReservRecord> list = reservRecordService.selectReservRecordList(reservRecord);
         return getDataTable(list);
@@ -45,8 +44,7 @@ public class ReservRecordController extends BaseController
     @PreAuthorize("@ss.hasPermi('wuYe:reservRecord:export')")
     @Log(title = "预约记录", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, ReservRecord reservRecord)
-    {
+    public void export(HttpServletResponse response, ReservRecord reservRecord) {
         List<ReservRecord> list = reservRecordService.selectReservRecordList(reservRecord);
         ExcelUtil<ReservRecord> util = new ExcelUtil<ReservRecord>(ReservRecord.class);
         util.exportExcel(response, list, "预约记录数据");
@@ -57,8 +55,7 @@ public class ReservRecordController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('wuYe:reservRecord:query')")
     @GetMapping(value = "/{reservRecordId}")
-    public AjaxResult getInfo(@PathVariable("reservRecordId") Long reservRecordId)
-    {
+    public AjaxResult getInfo(@PathVariable("reservRecordId") Long reservRecordId) {
         return success(reservRecordService.selectReservRecordByReservRecordId(reservRecordId));
     }
 
@@ -68,8 +65,7 @@ public class ReservRecordController extends BaseController
     @PreAuthorize("@ss.hasPermi('wuYe:reservRecord:add')")
     @Log(title = "预约记录", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody ReservRecord reservRecord)
-    {
+    public AjaxResult add(@RequestBody ReservRecord reservRecord) {
         return toAjax(reservRecordService.insertReservRecord(reservRecord));
     }
 
@@ -79,8 +75,7 @@ public class ReservRecordController extends BaseController
     @PreAuthorize("@ss.hasPermi('wuYe:reservRecord:edit')")
     @Log(title = "预约记录", businessType = BusinessType.UPDATE)
     @PostMapping("/put")
-    public AjaxResult edit(@RequestBody ReservRecord reservRecord)
-    {
+    public AjaxResult edit(@RequestBody ReservRecord reservRecord) {
         return toAjax(reservRecordService.updateReservRecord(reservRecord));
     }
 
@@ -90,8 +85,7 @@ public class ReservRecordController extends BaseController
     @PreAuthorize("@ss.hasPermi('wuYe:reservRecord:remove')")
     @Log(title = "预约记录", businessType = BusinessType.DELETE)
     @GetMapping("/delete/{reservRecordIds}")
-    public AjaxResult remove(@PathVariable Long[] reservRecordIds)
-    {
+    public AjaxResult remove(@PathVariable Long[] reservRecordIds) {
         return toAjax(reservRecordService.deleteReservRecordByReservRecordIds(reservRecordIds));
     }
 }

+ 77 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java

@@ -0,0 +1,77 @@
+package com.ruoyi.common.utils;
+
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * http 工具类
+ */
+public class HttpUtil {
+
+    public static String post(String requestUrl, String accessToken, String params)
+            throws Exception {
+        String contentType = "application/x-www-form-urlencoded";
+        return HttpUtil.post(requestUrl, accessToken, contentType, params);
+    }
+
+    public static String post(String requestUrl, String accessToken, String contentType, String params)
+            throws Exception {
+        String encoding = "UTF-8";
+        if (requestUrl.contains("nlp")) {
+            encoding = "GBK";
+        }
+        return HttpUtil.post(requestUrl, accessToken, contentType, params, encoding);
+    }
+
+    public static String post(String requestUrl, String accessToken, String contentType, String params, String encoding)
+            throws Exception {
+        String url = requestUrl + "?access_token=" + accessToken;
+        return HttpUtil.postGeneralUrl(url, contentType, params, encoding);
+    }
+
+    public static String postGeneralUrl(String generalUrl, String contentType, String params, String encoding)
+            throws Exception {
+        URL url = new URL(generalUrl);
+        // 打开和URL之间的连接
+        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+        connection.setRequestMethod("POST");
+        // 设置通用的请求属性
+        connection.setRequestProperty("Content-Type", contentType);
+        connection.setRequestProperty("Connection", "Keep-Alive");
+        connection.setUseCaches(false);
+        connection.setDoOutput(true);
+        connection.setDoInput(true);
+
+        // 得到请求的输出流对象
+        DataOutputStream out = new DataOutputStream(connection.getOutputStream());
+        out.write(params.getBytes(encoding));
+        out.flush();
+        out.close();
+
+        // 建立实际的连接
+        connection.connect();
+        // 获取所有响应头字段
+        Map<String, List<String>> headers = connection.getHeaderFields();
+        // 遍历所有的响应头字段
+        for (String key : headers.keySet()) {
+            System.err.println(key + "--->" + headers.get(key));
+        }
+        // 定义 BufferedReader输入流来读取URL的响应
+        BufferedReader in = null;
+        in = new BufferedReader(
+                new InputStreamReader(connection.getInputStream(), encoding));
+        String result = "";
+        String getLine;
+        while ((getLine = in.readLine()) != null) {
+            result += getLine;
+        }
+        in.close();
+        System.err.println("result:" + result);
+        return result;
+    }
+}

+ 205 - 7
ruoyi-common/src/main/java/com/ruoyi/common/utils/IdCardUtil.java

@@ -11,6 +11,7 @@ import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
 import com.ruoyi.common.core.domain.AjaxResult;
 import okhttp3.*;
+
 import javax.crypto.Cipher;
 import javax.crypto.spec.SecretKeySpec;
 import java.io.*;
@@ -547,6 +548,210 @@ public class IdCardUtil {
 
 
 
+    /**
+     * 重要提示代码中所需工具类
+     * FileUtil,Base64Util,HttpUtil,GsonUtils请从
+     * https://ai.baidu.com/file/658A35ABAB2D404FBF903F64D47C1F72
+     * https://ai.baidu.com/file/C8D81F3301E24D2892968F09AE1AD6E2
+     * https://ai.baidu.com/file/544D677F5D4E4F17B4122FBD60DB82B3
+     * https://ai.baidu.com/file/470B3ACCA3FE43788B5A963BF0B625F3
+     * 下载
+     * 车牌识别
+     */
+    public static AjaxResult licensePlate(String image) {
+        // 请求url
+        String url = "https://aip.baidubce.com/rest/2.0/ocr/v1/license_plate";
+        try {
+            // 本地文件路径
+            byte[] imgData = FileUtil.readFileByBytes(image);
+            String imgStr = com.ruoyi.common.utils.Base64Util.encode(imgData);
+            String imgParam = URLEncoder.encode(imgStr, "UTF-8");
+            String param = "image=" + imgParam;
+            // 注意这里仅为了简化编码每一次请求都去获取access_token,线上环境access_token有过期时间, 客户端可自行缓存,过期后重新获取。
+            String accessToken = getAccessToken("TvvuZOOh7MgnlDFnw11ln67n", "CY47OI0eKAzYBD2LO55SM3OITzsyq6DK");
+            String result = com.ruoyi.common.utils.HttpUtil.post(url, accessToken, param);
+            JSONObject jsonObject = JSONObject.parseObject(result);
+            String wordsResult = jsonObject.getString("words_result");
+            if (StringUtils.isNotEmpty(wordsResult)){
+                JSONObject jsonObjectWordsResult = JSON.parseObject(wordsResult);
+                String plateNumber = jsonObjectWordsResult.getString("number");
+                System.out.println("车牌:"+plateNumber);
+                return AjaxResult.success(plateNumber);
+            }
+            /**
+             *
+             {
+             "words_result": [
+             {
+             "color": "blue",
+             "number": "京KBT355",
+             "probability": [
+             0.9999992847,
+             0.999999404,
+             0.9999910593,
+             0.9999765158,
+             0.999994874,
+             0.9998959303,
+             0.9999984503
+             ],
+             "vertexes_location": [
+             {
+             "x": 495,
+             "y": 589
+             },
+             {
+             "x": 800,
+             "y": 587
+             },
+             {
+             "x": 800,
+             "y": 676
+             },
+             {
+             "x": 496,
+             "y": 678
+             }
+             ]
+             }
+             ],
+             "log_id": "6845817085824549137"
+             }
+             */
+            System.out.println(result);
+            return AjaxResult.error("识别车牌错误返回:"+result);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return AjaxResult.error();
+    }
+
+
+    /**
+     * 重要提示代码中所需工具类
+     * FileUtil,Base64Util,HttpUtil,GsonUtils请从
+     * https://ai.baidu.com/file/658A35ABAB2D404FBF903F64D47C1F72
+     * https://ai.baidu.com/file/C8D81F3301E24D2892968F09AE1AD6E2
+     * https://ai.baidu.com/file/544D677F5D4E4F17B4122FBD60DB82B3
+     * https://ai.baidu.com/file/470B3ACCA3FE43788B5A963BF0B625F3
+     * 下载
+     */
+    public static AjaxResult realEstateCertificate(String image) {
+        // 请求url
+        String url = "https://aip.baidubce.com/rest/2.0/ocr/v1/real_estate_certificate";
+        try {
+            // 本地文件路径
+            byte[] imgData = FileUtil.readFileByBytes(image);
+            String imgStr = com.ruoyi.common.utils.Base64Util.encode(imgData);
+            String imgParam = URLEncoder.encode(imgStr, "UTF-8");
+
+            String param = "image=" + imgParam;
+
+            // 注意这里仅为了简化编码每一次请求都去获取access_token,线上环境access_token有过期时间, 客户端可自行缓存,过期后重新获取。
+            String accessToken = getAccessToken("TvvuZOOh7MgnlDFnw11ln67n", "CY47OI0eKAzYBD2LO55SM3OITzsyq6DK");
+            String result = com.ruoyi.common.utils.HttpUtil.post(url, accessToken, param);
+
+            /**
+             *
+             {
+             "words_result_num": 11,
+             "words_result": {
+             "权利人": [
+             {
+             "word": "阮兴武"
+             }
+             ],
+             "坐落": [
+             {
+             "word": "吉水县乌江镇前江村丰山组"
+             }
+             ],
+             "权利类型": [
+             {
+             "word": "宅基地使用权/房屋(构筑物)所有权"
+             }
+             ],
+             "面积": [
+             {
+             "word": "土地使用权面积:115.720㎡/房屋建筑面积:298.520㎡"
+             }
+             ],
+             "字第号": [
+             {
+             "word": "0042537"
+             }
+             ],
+             "不动产单元号": [
+             {
+             "word": "360822"
+             }
+             ],
+             "共有情况": [
+             {
+             "word": "家庭成员共有"
+             }
+             ],
+             "用途": [
+             {
+             "word": "农村宅基地/住宅"
+             }
+             ],
+             "使用期限": [
+             {
+             "word": ""
+             }
+             ],
+             "登记日期": [
+             {
+             "word": ""
+             }
+             ],
+             "共有人": [
+             {
+             "word": ""
+             }
+             ]
+             },
+             "log_id": 1739493844726379007
+             }
+             */
+            JSONObject jsonObject = JSONObject.parseObject(result);
+            String wordsResult = jsonObject.getString("words_result");
+            Map<String, Object> map = new HashMap<>(11);
+            if (StringUtils.isNotEmpty(wordsResult)) {
+                JSONObject jsonObjectWordsResult = JSON.parseObject(wordsResult);
+                String ownerName = JSON.parseObject(jsonObjectWordsResult.getString("权利人")).getString("words");
+                String location = JSON.parseObject(jsonObjectWordsResult.getString("坐落")).getString("words");
+                String rightType = JSON.parseObject(jsonObjectWordsResult.getString("权利类型")).getString("words");
+                String area = JSON.parseObject(jsonObjectWordsResult.getString("面积")).getString("words");
+                String documentNumber = JSON.parseObject(jsonObjectWordsResult.getString("字第号")).getString("words");
+                String propertyUnitNumber = JSON.parseObject(jsonObjectWordsResult.getString("不动产单元号")).getString("words");
+                String coOwnership = JSON.parseObject(jsonObjectWordsResult.getString("共有情况")).getString("words");
+                String usageType = JSON.parseObject(jsonObjectWordsResult.getString("用途")).getString("words");
+                String usagePeriod = JSON.parseObject(jsonObjectWordsResult.getString("使用期限")).getString("words");
+                String registrationDate = JSON.parseObject(jsonObjectWordsResult.getString("登记日期")).getString("words");
+                String coOwner = JSON.parseObject(jsonObjectWordsResult.getString("共有人")).getString("words");
+                map.put("ownerName", ownerName);
+                map.put("location", location);
+                map.put("rightType", rightType);
+                map.put("area", area);
+                map.put("documentNumber", documentNumber);
+                map.put("propertyUnitNumber", propertyUnitNumber);
+                map.put("coOwnership", coOwnership);
+                map.put("usageType", usageType);
+                map.put("usagePeriod", usagePeriod);
+                map.put("registrationDate", registrationDate);
+                map.put("coOwner", coOwner);
+            } else {
+                return AjaxResult.error("房产证识别失败,请检查。");
+            }
+            System.out.println(result);
+            return AjaxResult.success(map);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return AjaxResult.error();
+    }
+
     /**
      * 获取文件base64编码
      *
@@ -599,12 +804,5 @@ public class IdCardUtil {
 
 
 
-
-
-
-
-
-
-
     static final OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder().build();
 }

+ 3 - 1
ruoyi-system/src/main/java/com/ruoyi/system/listener/RedisKeyExpirationListener.java

@@ -71,6 +71,7 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
             communityNews.setCommunityId(Long.parseLong(splitResult[0]));
             communityNews.setUserLikes(splitResult[1]);
             communityNewsMapper.updateCommunityNews(communityNews);
+            System.out.println("监听key文章的点赞:"+expiredKey);
         }else if (expiredKey.contains(TWO_LIKE_COUNT_TIME)){
             //处理评论的点赞数量
             String[] split = expiredKey.split(":");
@@ -80,8 +81,9 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
             commentContent.setCommentId(Long.parseLong(splitResult[0]));
             commentContent.setLikeCount(Long.parseLong(splitResult[1]));
             commentContentMapper.updateCommentContentByCommentId(commentContent);
+            System.out.println("监听key评论的点赞:"+expiredKey);
         }
-        System.out.println("监听key:"+expiredKey);
+
     }
     public Topic getTop() {
         return top;

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CheckPointManageServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ruoyi.system.service.impl;
 
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.system.domain.checkPoint.CheckPointManage;
 import com.ruoyi.system.mapper.CheckPointManageMapper;
 import com.ruoyi.system.service.ICheckPointManageService;
@@ -55,6 +56,7 @@ public class CheckPointManageServiceImpl implements ICheckPointManageService
     public int insertCheckPointManage(CheckPointManage checkPointManage)
     {
         checkPointManage.setCreateTime(DateUtils.getNowDate());
+        checkPointManage.setUseId(SecurityUtils.getUserId());
         return checkPointManageMapper.insertCheckPointManage(checkPointManage);
     }
 

+ 1 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ProprietorCarServiceImpl.java

@@ -1,7 +1,6 @@
 package com.ruoyi.system.service.impl;
 
 import com.ruoyi.common.utils.DateUtils;
-import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.system.domain.proprietorCar.ProprietorCar;
 import com.ruoyi.system.mapper.ProprietorCarMapper;
 import com.ruoyi.system.service.IProprietorCarService;
@@ -64,7 +63,7 @@ public class ProprietorCarServiceImpl implements IProprietorCarService {
             vehicleType = "新能源";
         }
         proprietorCar.setVehicleType(vehicleType);
-        proprietorCar.setUserId(SecurityUtils.getUserId());
+        //proprietorCar.setUserId(SecurityUtils.getUserId());
         return proprietorCarMapper.insertProprietorCar(proprietorCar);
     }
 

+ 1 - 0
ruoyi-system/src/main/resources/mapper/system/HouseInfoMapper.xml

@@ -107,6 +107,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <where>
             <if test="residentName != null  and residentName != ''"> and r.resident_name like concat('%', #{residentName}, '%')</if>
             <if test="residentAppearance != null  and residentAppearance != ''"> and r.resident_appearance = #{residentAppearance}</if>
+            <if test="residentAppearance != null  and residentAppearance != ''"> and r.user_id = #{userId}</if>
         </where>
     </select>