Prechádzať zdrojové kódy

fix 文章上传新增附件,新增小程序二维码查询,新增签发日期

tjf 3 rokov pred
rodič
commit
919c48fd9c

+ 29 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/QueryController.java

@@ -16,6 +16,7 @@ import com.ruoyi.framework.config.ServerConfig;
 import com.ruoyi.system.domain.*;
 import com.ruoyi.system.service.*;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -59,6 +60,9 @@ public class QueryController extends BaseController {
     @Autowired
     private ISysDictTypeService dictTypeService;
 
+    @Autowired
+    private IMiniprogramQueryLogService miniprogramQueryLogService;
+
     /**
      * 门户查询报告信息
      */
@@ -72,12 +76,21 @@ public class QueryController extends BaseController {
     /**
      * 小程序根据二维码查询
      */
-    @PostMapping("/queryQr")
+    //@PostMapping("/queryQr")
     public AjaxResult queryQr(ReportQueryLog reportQueryLog)
     {
         return queryService.queryQr(reportQueryLog);
     }
 
+    /**
+     * 小程序根据编号查询
+     */
+    @PostMapping("/queryReportNum")
+    public AjaxResult queryReportNum(ReportQueryLog reportQueryLog)
+    {
+        return queryService.queryReportNum(reportQueryLog);
+    }
+
 
     /**
      * 获取栏目导航下拉树列表
@@ -246,4 +259,19 @@ public class QueryController extends BaseController {
         return AjaxResult.success(data);
     }
 
+
+    /**
+     * 查询小程序查询历史记录列表
+     */
+    @PostMapping("/miniProgramQueryLog")
+    public TableDataInfo list(MiniprogramQueryLog miniprogramQueryLog)
+    {
+        startPage();
+        List<MiniprogramQueryLog> list = miniprogramQueryLogService.selectMiniprogramQueryLogList(miniprogramQueryLog);
+        return getDataTable(list);
+    }
+
+
+
+
 }

+ 80 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/WechatController.java

@@ -0,0 +1,80 @@
+package com.ruoyi.web.controller.system;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.aliyuncs.http.HttpRequest;
+import com.aliyuncs.http.HttpUtil;
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.core.domain.model.LoginUser;
+import com.ruoyi.common.enums.UserStatus;
+import com.ruoyi.common.exception.base.BaseException;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.http.HttpClientUtils;
+import com.ruoyi.common.utils.http.HttpUtils;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import oshi.driver.mac.net.NetStat;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author tjf
+ * @Date: 2022/02/22/14:11
+ */
+@RestController
+@RequestMapping("/weChat")
+public class WechatController {
+
+    @PostMapping("/login")
+    public AjaxResult getPhone(@RequestBody String code) {
+        if (StringUtils.isNotBlank(code)) {
+            code = JSONObject.parseObject(code).getString("code");
+        }
+        String appSecret = "3989febf241b1ddd5a5411333a65303a";
+        String appId = "wxa7b61655bfecc7bd";
+        //获取接口调用凭证
+        String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appId + "&secret=" + appSecret;
+        String jsonStr = HttpUtils.sendGet(url);
+        JSONObject result = JSONObject.parseObject(jsonStr);
+        //{"access_token":"ACCESS_TOKEN","expires_in":7200}
+        String accessToken = result.getString("access_token");
+        if (StringUtils.isNotBlank(accessToken)) {
+            //获取手机号
+            String phoneUrl = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + accessToken;
+            JSONObject json = new JSONObject();
+            json.put("code",code);
+            String strPhone = null;
+            try {
+                strPhone = HttpClientUtils.doPost(phoneUrl, json);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+            //{
+            //    "errcode":0,
+            //    "errmsg":"ok",
+            //    "phone_info": {
+            //        "phoneNumber":"xxxxxx",
+            //        "purePhoneNumber": "xxxxxx",
+            //        "countryCode": 86,
+            //        "watermark": {
+            //            "timestamp": 1637744274,
+            //            "appid": "xxxx"
+            //        }
+            //    }
+            //}
+            JSONObject resultPhone = JSONObject.parseObject(strPhone);
+            String errmsg = resultPhone.getString("errmsg");
+            if ("ok".equals(errmsg)) {
+                String phone = JSONObject.parseObject(resultPhone.getString("phone_info")).getString("phoneNumber");
+                return AjaxResult.success(phone);
+            }
+        }
+        return AjaxResult.error("获取手机号失败");
+    }
+}

+ 121 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpClientUtils.java

@@ -0,0 +1,121 @@
+package com.ruoyi.common.utils.http;
+
+import com.alibaba.fastjson.JSONObject;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.protocol.HTTP;
+import org.apache.http.util.EntityUtils;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class HttpClientUtils {
+
+    final static int TIMEOUT = 1000;
+    final static int TIMEOUT_MSEC = 5 * 1000;
+
+    public static String doPost(String url, JSONObject json) throws IOException {
+        // 创建Httpclient对象
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        CloseableHttpResponse response = null;
+        String resultString = "";
+        try {
+            // 创建Http Post请求
+            HttpPost httpPost = new HttpPost(url);
+/*            // 创建参数列表
+            if (paramMap != null) {
+                List<NameValuePair> paramList = new ArrayList<>();
+                for (Map.Entry<String, String> param : paramMap.entrySet()) {
+                    paramList.add(new BasicNameValuePair(param.getKey(), param.getValue()));
+                }
+                // 模拟表单
+                UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList);
+                httpPost.setEntity(entity);
+            }*/
+
+            StringEntity s = new StringEntity(json.toString(), "utf-8");
+            s.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,
+                    "application/json"));
+            httpPost.setEntity(s);
+
+            httpPost.setConfig(builderRequestConfig());
+
+            // 执行http请求
+            response = httpClient.execute(httpPost);
+
+            resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
+        } catch (Exception e) {
+            throw e;
+        } finally {
+            try {
+                response.close();
+            } catch (IOException e) {
+                throw e;
+            }
+        }
+
+        return resultString;
+    }
+
+    public static String doGet(String url, Map<String, String> paramMap) throws IOException {
+        url += "?appid=" + paramMap.get("appid") + "&secret=" + paramMap.get("secret") + "&js_code=" + paramMap.get("js_code") + "&grant_type=" + paramMap.get("grant_type");
+        // 创建Httpclient对象
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        CloseableHttpResponse response = null;
+        String resultString = "";
+        try {
+            // 创建Http Post请求
+            HttpGet httpGet = new HttpGet(url);
+            // 执行http请求
+            response = httpClient.execute(httpGet);
+            resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
+        } catch (Exception e) {
+            throw e;
+        } finally {
+            try {
+                response.close();
+            } catch (IOException e) {
+                throw e;
+            }
+        }
+        return resultString;
+    }
+
+    public static String doGet1(String url) throws IOException {
+        // 创建Httpclient对象
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        CloseableHttpResponse response = null;
+        String resultString = "";
+        try {
+            // 创建Http Post请求
+            HttpGet httpGet = new HttpGet(url);
+            // 执行http请求
+            response = httpClient.execute(httpGet);
+            resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
+        } catch (Exception e) {
+            throw e;
+        } finally {
+            assert response != null;
+            response.close();
+        }
+        return resultString;
+    }
+
+    private static RequestConfig builderRequestConfig() {
+        return RequestConfig.custom()
+                .setConnectTimeout(TIMEOUT_MSEC)
+                .setConnectionRequestTimeout(TIMEOUT_MSEC)
+                .setSocketTimeout(TIMEOUT_MSEC).build();
+    }
+}

+ 1 - 0
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java

@@ -113,6 +113,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 .antMatchers("/*/api-docs").anonymous()
                 .antMatchers("/druid/**").anonymous()
                 .antMatchers("/gateway/query/**").anonymous()
+                .antMatchers("/weChat/**").anonymous()
                 // 除上面外的所有请求全部需要鉴权认证
                 .anyRequest().authenticated()
                 .and()

+ 98 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/MiniprogramQueryLog.java

@@ -0,0 +1,98 @@
+package com.ruoyi.system.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * 小程序查询历史记录对象 miniprogram_query_log
+ * 
+ * @author boman
+ * @date 2022-02-21
+ */
+public class MiniprogramQueryLog extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 查询日志ID */
+    private Long logId;
+
+    /** 报告编号 */
+    @Excel(name = "报告编号")
+    private String reportNumber;
+
+    /** 查询人手机号 */
+    @Excel(name = "查询人手机号")
+    private String queryPhone;
+
+    /** 查询方式(1 二维码 2 粗略 ) */
+    @Excel(name = "查询方式(1 二维码 2 粗略 )")
+    private String queryMode;
+
+    /** 是否删除(N正常 Y删除) */
+    @Excel(name = "是否删除", readConverterExp = "N=正常,Y=删除")
+    private String isDel;
+
+    public void setLogId(Long logId) 
+    {
+        this.logId = logId;
+    }
+
+    public Long getLogId() 
+    {
+        return logId;
+    }
+    public void setReportNumber(String reportNumber) 
+    {
+        this.reportNumber = reportNumber;
+    }
+
+    public String getReportNumber() 
+    {
+        return reportNumber;
+    }
+    public void setQueryPhone(String queryPhone) 
+    {
+        this.queryPhone = queryPhone;
+    }
+
+    public String getQueryPhone() 
+    {
+        return queryPhone;
+    }
+    public void setQueryMode(String queryMode) 
+    {
+        this.queryMode = queryMode;
+    }
+
+    public String getQueryMode() 
+    {
+        return queryMode;
+    }
+    public void setIsDel(String isDel) 
+    {
+        this.isDel = isDel;
+    }
+
+    public String getIsDel() 
+    {
+        return isDel;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("logId", getLogId())
+            .append("reportNumber", getReportNumber())
+            .append("queryPhone", getQueryPhone())
+            .append("queryMode", getQueryMode())
+            .append("isDel", getIsDel())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .append("remark", getRemark())
+            .toString();
+    }
+}

+ 16 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/ReportDetail.java

@@ -1,10 +1,13 @@
 package com.ruoyi.system.domain;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
 
+import java.util.Date;
+
 /**
  * 报告信息对象 report_detail
  * 
@@ -45,6 +48,11 @@ public class ReportDetail extends BaseEntity
     /** 报告图片 */
     @Excel(name = "报告图片")
     private String reportUrl;
+    /**
+     * 签发日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date issueTime;
     /**
      * 二维码地址
      */
@@ -59,6 +67,14 @@ public class ReportDetail extends BaseEntity
      */
     private String phonenumber;
 
+    public Date getIssueTime() {
+        return issueTime;
+    }
+
+    public void setIssueTime(Date issueTime) {
+        this.issueTime = issueTime;
+    }
+
     public String getQrPath() {
         return qrPath;
     }

+ 61 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/MiniprogramQueryLogMapper.java

@@ -0,0 +1,61 @@
+package com.ruoyi.system.mapper;
+
+import java.util.List;
+import com.ruoyi.system.domain.MiniprogramQueryLog;
+
+/**
+ * 小程序查询历史记录Mapper接口
+ * 
+ * @author boman
+ * @date 2022-02-21
+ */
+public interface MiniprogramQueryLogMapper 
+{
+    /**
+     * 查询小程序查询历史记录
+     * 
+     * @param logId 小程序查询历史记录主键
+     * @return 小程序查询历史记录
+     */
+    public MiniprogramQueryLog selectMiniprogramQueryLogByLogId(Long logId);
+
+    /**
+     * 查询小程序查询历史记录列表
+     * 
+     * @param miniprogramQueryLog 小程序查询历史记录
+     * @return 小程序查询历史记录集合
+     */
+    public List<MiniprogramQueryLog> selectMiniprogramQueryLogList(MiniprogramQueryLog miniprogramQueryLog);
+
+    /**
+     * 新增小程序查询历史记录
+     * 
+     * @param miniprogramQueryLog 小程序查询历史记录
+     * @return 结果
+     */
+    public int insertMiniprogramQueryLog(MiniprogramQueryLog miniprogramQueryLog);
+
+    /**
+     * 修改小程序查询历史记录
+     * 
+     * @param miniprogramQueryLog 小程序查询历史记录
+     * @return 结果
+     */
+    public int updateMiniprogramQueryLog(MiniprogramQueryLog miniprogramQueryLog);
+
+    /**
+     * 删除小程序查询历史记录
+     * 
+     * @param logId 小程序查询历史记录主键
+     * @return 结果
+     */
+    public int deleteMiniprogramQueryLogByLogId(Long logId);
+
+    /**
+     * 批量删除小程序查询历史记录
+     * 
+     * @param logIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteMiniprogramQueryLogByLogIds(Long[] logIds);
+}

+ 61 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/IMiniprogramQueryLogService.java

@@ -0,0 +1,61 @@
+package com.ruoyi.system.service;
+
+import java.util.List;
+import com.ruoyi.system.domain.MiniprogramQueryLog;
+
+/**
+ * 小程序查询历史记录Service接口
+ * 
+ * @author boman
+ * @date 2022-02-21
+ */
+public interface IMiniprogramQueryLogService 
+{
+    /**
+     * 查询小程序查询历史记录
+     * 
+     * @param logId 小程序查询历史记录主键
+     * @return 小程序查询历史记录
+     */
+    public MiniprogramQueryLog selectMiniprogramQueryLogByLogId(Long logId);
+
+    /**
+     * 查询小程序查询历史记录列表
+     * 
+     * @param miniprogramQueryLog 小程序查询历史记录
+     * @return 小程序查询历史记录集合
+     */
+    public List<MiniprogramQueryLog> selectMiniprogramQueryLogList(MiniprogramQueryLog miniprogramQueryLog);
+
+    /**
+     * 新增小程序查询历史记录
+     * 
+     * @param miniprogramQueryLog 小程序查询历史记录
+     * @return 结果
+     */
+    public int insertMiniprogramQueryLog(MiniprogramQueryLog miniprogramQueryLog);
+
+    /**
+     * 修改小程序查询历史记录
+     * 
+     * @param miniprogramQueryLog 小程序查询历史记录
+     * @return 结果
+     */
+    public int updateMiniprogramQueryLog(MiniprogramQueryLog miniprogramQueryLog);
+
+    /**
+     * 批量删除小程序查询历史记录
+     * 
+     * @param logIds 需要删除的小程序查询历史记录主键集合
+     * @return 结果
+     */
+    public int deleteMiniprogramQueryLogByLogIds(Long[] logIds);
+
+    /**
+     * 删除小程序查询历史记录信息
+     * 
+     * @param logId 小程序查询历史记录主键
+     * @return 结果
+     */
+    public int deleteMiniprogramQueryLogByLogId(Long logId);
+}

+ 7 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/IQueryService.java

@@ -24,6 +24,13 @@ public interface IQueryService {
      */
     AjaxResult queryQr (ReportQueryLog reportQueryLog);
 
+    /**
+     * 小程序根据编号查询
+     * @param reportQueryLog
+     * @return
+     */
+    AjaxResult queryReportNum (ReportQueryLog reportQueryLog);
+
 
     /**
      * 发送查询码

+ 96 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MiniprogramQueryLogServiceImpl.java

@@ -0,0 +1,96 @@
+package com.ruoyi.system.service.impl;
+
+import java.util.List;
+import com.ruoyi.common.utils.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.system.mapper.MiniprogramQueryLogMapper;
+import com.ruoyi.system.domain.MiniprogramQueryLog;
+import com.ruoyi.system.service.IMiniprogramQueryLogService;
+
+/**
+ * 小程序查询历史记录Service业务层处理
+ * 
+ * @author boman
+ * @date 2022-02-21
+ */
+@Service
+public class MiniprogramQueryLogServiceImpl implements IMiniprogramQueryLogService 
+{
+    @Autowired
+    private MiniprogramQueryLogMapper miniprogramQueryLogMapper;
+
+    /**
+     * 查询小程序查询历史记录
+     * 
+     * @param logId 小程序查询历史记录主键
+     * @return 小程序查询历史记录
+     */
+    @Override
+    public MiniprogramQueryLog selectMiniprogramQueryLogByLogId(Long logId)
+    {
+        return miniprogramQueryLogMapper.selectMiniprogramQueryLogByLogId(logId);
+    }
+
+    /**
+     * 查询小程序查询历史记录列表
+     * 
+     * @param miniprogramQueryLog 小程序查询历史记录
+     * @return 小程序查询历史记录
+     */
+    @Override
+    public List<MiniprogramQueryLog> selectMiniprogramQueryLogList(MiniprogramQueryLog miniprogramQueryLog)
+    {
+        return miniprogramQueryLogMapper.selectMiniprogramQueryLogList(miniprogramQueryLog);
+    }
+
+    /**
+     * 新增小程序查询历史记录
+     * 
+     * @param miniprogramQueryLog 小程序查询历史记录
+     * @return 结果
+     */
+    @Override
+    public int insertMiniprogramQueryLog(MiniprogramQueryLog miniprogramQueryLog)
+    {
+        miniprogramQueryLog.setCreateTime(DateUtils.getNowDate());
+        return miniprogramQueryLogMapper.insertMiniprogramQueryLog(miniprogramQueryLog);
+    }
+
+    /**
+     * 修改小程序查询历史记录
+     * 
+     * @param miniprogramQueryLog 小程序查询历史记录
+     * @return 结果
+     */
+    @Override
+    public int updateMiniprogramQueryLog(MiniprogramQueryLog miniprogramQueryLog)
+    {
+        miniprogramQueryLog.setUpdateTime(DateUtils.getNowDate());
+        return miniprogramQueryLogMapper.updateMiniprogramQueryLog(miniprogramQueryLog);
+    }
+
+    /**
+     * 批量删除小程序查询历史记录
+     * 
+     * @param logIds 需要删除的小程序查询历史记录主键
+     * @return 结果
+     */
+    @Override
+    public int deleteMiniprogramQueryLogByLogIds(Long[] logIds)
+    {
+        return miniprogramQueryLogMapper.deleteMiniprogramQueryLogByLogIds(logIds);
+    }
+
+    /**
+     * 删除小程序查询历史记录信息
+     * 
+     * @param logId 小程序查询历史记录主键
+     * @return 结果
+     */
+    @Override
+    public int deleteMiniprogramQueryLogByLogId(Long logId)
+    {
+        return miniprogramQueryLogMapper.deleteMiniprogramQueryLogByLogId(logId);
+    }
+}

+ 38 - 10
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/QueryServiceImpl.java

@@ -3,18 +3,18 @@ package com.ruoyi.system.service.impl;
 import com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsResponse;
 import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
 import com.aliyuncs.exceptions.ClientException;
-import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.constant.UserConstants;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.redis.RedisCache;
-import com.ruoyi.common.exception.user.CaptchaException;
-import com.ruoyi.common.exception.user.CaptchaExpireException;
+import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.QRCodeUtils;
 import com.ruoyi.common.utils.SendSmsUtils;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.system.domain.MiniprogramQueryLog;
 import com.ruoyi.system.domain.QueryConfig;
 import com.ruoyi.system.domain.ReportDetail;
 import com.ruoyi.system.domain.ReportQueryLog;
+import com.ruoyi.system.mapper.MiniprogramQueryLogMapper;
 import com.ruoyi.system.mapper.QueryConfigMapper;
 import com.ruoyi.system.mapper.ReportDetailMapper;
 import com.ruoyi.system.mapper.ReportQueryLogMapper;
@@ -23,10 +23,12 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+
 import java.util.Calendar;
 import java.util.concurrent.TimeUnit;
 
 import static com.ruoyi.common.core.domain.AjaxResult.MSG_TAG;
+import static com.ruoyi.common.utils.SecurityUtils.getUsername;
 
 /**
  * @author tjf
@@ -47,6 +49,9 @@ public class QueryServiceImpl implements IQueryService {
     @Autowired
     private QueryConfigMapper queryConfigMapper;
 
+    @Autowired
+    private MiniprogramQueryLogMapper miniprogramQueryLogMapper;
+
 
     //短信参数
     @Value("${sms_aliyun_accessKeyId}")
@@ -103,8 +108,6 @@ public class QueryServiceImpl implements IQueryService {
         String remark = "";
         if (StringUtils.isBlank(qrImage)) {
             remark = "未接收到二维码";
-            reportQueryLog.setRemark(remark);
-            reportQueryLogMapper.insertReportQueryLog(reportQueryLog);
             return AjaxResult.error(remark);
         }
         try {
@@ -112,8 +115,6 @@ public class QueryServiceImpl implements IQueryService {
             String reportNumber = QRCodeUtils.decode(qrImage);
             if (StringUtils.isBlank(reportNumber)) {
                 remark = "二维码解析失败";
-                reportQueryLog.setRemark(remark);
-                reportQueryLogMapper.insertReportQueryLog(reportQueryLog);
                 return AjaxResult.error(remark);
             }
 /*            //查询二维码有效期
@@ -128,9 +129,13 @@ public class QueryServiceImpl implements IQueryService {
             ReportDetail reportDetail = reportDetailMapper.selectReportDetailByReportNumber(reportNumber);
             if (reportDetail != null) {
                 reportDetail.setReportUrl(null);
-                reportQueryLog.setIsSuccess("Y");
-                reportQueryLog.setRemark(UserConstants.QUERY_SUCCESS);
-                reportQueryLogMapper.insertReportQueryLog(reportQueryLog);
+                MiniprogramQueryLog miniprogramQueryLog = new MiniprogramQueryLog();
+                miniprogramQueryLog.setReportNumber(reportNumber);
+                miniprogramQueryLog.setQueryPhone(reportQueryLog.getQueryPhone());
+                miniprogramQueryLog.setCreateTime(DateUtils.getNowDate());
+                miniprogramQueryLog.setCreateBy(reportQueryLog.getQueryPhone());
+                miniprogramQueryLog.setQueryMode("1");
+                miniprogramQueryLogMapper.insertMiniprogramQueryLog(miniprogramQueryLog);
                 return AjaxResult.success(reportDetail);
             }
         } catch (Exception e) {
@@ -140,6 +145,29 @@ public class QueryServiceImpl implements IQueryService {
         return AjaxResult.error("未查询到对应信息");
     }
 
+    /**
+     * 小程序根据编号查询
+     * @param reportQueryLog
+     * @return
+     */
+    @Override
+    public AjaxResult queryReportNum(ReportQueryLog reportQueryLog) {
+        String reportNumber = reportQueryLog.getReportNumber();
+        ReportDetail reportDetail = reportDetailMapper.selectReportDetailByReportNumber(reportNumber);
+        if (reportDetail != null) {
+            reportDetail.setReportUrl(null);
+            MiniprogramQueryLog miniprogramQueryLog = new MiniprogramQueryLog();
+            miniprogramQueryLog.setReportNumber(reportNumber);
+            miniprogramQueryLog.setQueryPhone(reportQueryLog.getQueryPhone());
+            miniprogramQueryLog.setCreateTime(DateUtils.getNowDate());
+            miniprogramQueryLog.setCreateBy(reportQueryLog.getQueryPhone());
+            miniprogramQueryLog.setQueryMode("2");
+            miniprogramQueryLogMapper.insertMiniprogramQueryLog(miniprogramQueryLog);
+            return AjaxResult.success(reportDetail);
+        }
+        return AjaxResult.error("查询的文档编号不存在");
+    }
+
     /**
      * 发送短信验证码
      *

+ 90 - 0
ruoyi-system/src/main/resources/mapper/system/MiniprogramQueryLogMapper.xml

@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.system.mapper.MiniprogramQueryLogMapper">
+    
+    <resultMap type="com.ruoyi.system.domain.MiniprogramQueryLog" id="MiniprogramQueryLogResult">
+        <result property="logId"    column="log_id"    />
+        <result property="reportNumber"    column="report_number"    />
+        <result property="queryPhone"    column="query_phone"    />
+        <result property="queryMode"    column="query_mode"    />
+        <result property="isDel"    column="is_del"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="remark"    column="remark"    />
+    </resultMap>
+
+    <sql id="selectMiniprogramQueryLogVo">
+        select log_id, report_number, query_phone, query_mode, is_del, create_by, create_time, update_by, update_time, remark from miniprogram_query_log
+    </sql>
+
+    <select id="selectMiniprogramQueryLogList" parameterType="MiniprogramQueryLog" resultMap="MiniprogramQueryLogResult">
+        <include refid="selectMiniprogramQueryLogVo"/>
+        <where>
+            is_del = 'N'
+            <if test="reportNumber != null  and reportNumber != ''"> and report_number = #{reportNumber}</if>
+            <if test="queryPhone != null  and queryPhone != ''"> and query_phone = #{queryPhone}</if>
+        </where>
+    </select>
+    
+    <select id="selectMiniprogramQueryLogByLogId" parameterType="Long" resultMap="MiniprogramQueryLogResult">
+        <include refid="selectMiniprogramQueryLogVo"/>
+        where log_id = #{logId}
+    </select>
+        
+    <insert id="insertMiniprogramQueryLog" parameterType="MiniprogramQueryLog" useGeneratedKeys="true" keyProperty="logId">
+        insert into miniprogram_query_log
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="reportNumber != null">report_number,</if>
+            <if test="queryPhone != null">query_phone,</if>
+            <if test="queryMode != null">query_mode,</if>
+            <if test="isDel != null">is_del,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="remark != null">remark,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="reportNumber != null">#{reportNumber},</if>
+            <if test="queryPhone != null">#{queryPhone},</if>
+            <if test="queryMode != null">#{queryMode},</if>
+            <if test="isDel != null">#{isDel},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="remark != null">#{remark},</if>
+         </trim>
+    </insert>
+
+    <update id="updateMiniprogramQueryLog" parameterType="MiniprogramQueryLog">
+        update miniprogram_query_log
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="reportNumber != null">report_number = #{reportNumber},</if>
+            <if test="queryPhone != null">query_phone = #{queryPhone},</if>
+            <if test="queryMode != null">query_mode = #{queryMode},</if>
+            <if test="isDel != null">is_del = #{isDel},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="remark != null">remark = #{remark},</if>
+        </trim>
+        where log_id = #{logId}
+    </update>
+
+    <delete id="deleteMiniprogramQueryLogByLogId" parameterType="Long">
+        delete from miniprogram_query_log where log_id = #{logId}
+    </delete>
+
+    <delete id="deleteMiniprogramQueryLogByLogIds" parameterType="String">
+        delete from miniprogram_query_log where log_id in 
+        <foreach item="logId" collection="array" open="(" separator="," close=")">
+            #{logId}
+        </foreach>
+    </delete>
+</mapper>

+ 7 - 3
ruoyi-system/src/main/resources/mapper/system/ReportDetailMapper.xml

@@ -13,6 +13,7 @@
         <result property="entrustName" column="entrust_name"/>
         <result property="isQualify" column="is_qualify"/>
         <result property="reportUrl" column="report_url"/>
+        <result property="issueTime" column="issue_time"/>
         <result property="qrPath"    column="qr_path"    />
         <result property="isDel" column="is_del"/>
         <result property="createBy" column="create_by"/>
@@ -24,7 +25,7 @@
     </resultMap>
 
     <sql id="selectReportDetailVo">
-        select report_id, report_number, inspect_id, sample_name, inspect_name, entrust_name, is_qualify, report_url,qr_path, is_del, create_by, create_time, update_by, update_time, remark from report_detail
+        select report_id, report_number, inspect_id, sample_name, inspect_name, entrust_name, is_qualify, report_url,issue_time,qr_path, is_del, create_by, create_time, update_by, update_time, remark from report_detail
     </sql>
 
     <select id="selectReportDetailList" parameterType="ReportDetail" resultMap="ReportDetailResult">
@@ -62,6 +63,7 @@
             <if test="entrustName != null">entrust_name,</if>
             <if test="isQualify != null">is_qualify,</if>
             <if test="reportUrl != null">report_url,</if>
+            <if test="issueTime != null">issue_time,</if>
             <if test="qrPath != null">qr_path,</if>
             <if test="createBy != null">create_by,</if>
             <if test="createTime != null">create_time,</if>
@@ -74,6 +76,7 @@
             <if test="entrustName != null">#{entrustName},</if>
             <if test="isQualify != null">#{isQualify},</if>
             <if test="reportUrl != null">#{reportUrl},</if>
+            <if test="issueTime != null">#{issueTime},</if>
             <if test="qrPath != null">#{qrPath},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="createTime != null">#{createTime},</if>
@@ -90,6 +93,7 @@
             <if test="entrustName != null">entrust_name = #{entrustName},</if>
             <if test="isQualify != null">is_qualify = #{isQualify},</if>
             <if test="reportUrl != null">report_url = #{reportUrl},</if>
+            <if test="issueTime != null">issue_time = #{issueTime},</if>
             <if test="qrPath != null">qr_path = #{qrPath},</if>
             <if test="isDel != null">is_del = #{isDel},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
@@ -118,12 +122,12 @@
     </select>
 
     <select id="selectReportDetailByReportNumber" resultMap="ReportDetailResult">
-     select  r.report_number,  r.sample_name, r.inspect_name, r.entrust_name, r.is_qualify, r.report_url from report_detail r
+     select  r.report_number,  r.sample_name, r.inspect_name, r.entrust_name, r.is_qualify, r.report_url,r.issueTime from report_detail r
         where r.report_number=#{reportNumber} and r.is_del = 'N'  limit 1
     </select>
 
     <select id="selectReportDetailByReportNumberDetail" resultMap="ReportDetailResult">
-     select  r.report_number,  r.sample_name, r.inspect_name, r.entrust_name, r.is_qualify, r.report_url,s.phonenumber from report_detail r left join sys_user s on r.create_by = s.create_by
+     select  r.report_number,  r.sample_name, r.inspect_name, r.entrust_name, r.is_qualify, r.report_url,s.phonenumber,r.issueTime from report_detail r left join sys_user s on r.create_by = s.create_by
         where r.report_number=#{reportNumber} and r.is_del = 'N' and s.status = '0' and s.del_flag = '0' limit 1
     </select>