LIVE_YE 2 هفته پیش
والد
کامیت
845a17a828

+ 15 - 1
ruoyi-admin/pom.xml

@@ -9,7 +9,7 @@
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <packaging>jar</packaging>
-    <artifactId>ruoyi-admin</artifactId>
+    <artifactId>gongdan</artifactId>
 
     <description>
         web服务入口
@@ -61,6 +61,20 @@
             <artifactId>ruoyi-generator</artifactId>
         </dependency>
 
+
+        <dependency>
+            <groupId>com.github.binarywang</groupId>
+            <artifactId>weixin-java-mp</artifactId>
+            <version>4.5.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+        </dependency>
+
+
     </dependencies>
 
     <build>

+ 205 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/wx/WxMsgController.java

@@ -0,0 +1,205 @@
+package com.ruoyi.web.controller.wx;
+
+import com.google.gson.Gson;
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.core.domain.model.LoginBody;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.wxMessage.WxMpPropertiesConfig;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.utils.StringUtils;
+
+import com.ruoyi.framework.web.service.SysLoginService;
+import com.ruoyi.system.service.WxMsgService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.boot.configurationprocessor.json.JSONObject;
+import org.springframework.http.ResponseEntity;
+import org.springframework.http.converter.StringHttpMessageConverter;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.client.RestTemplate;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.util.*;
+
+import static com.ruoyi.common.constant.Constants.OPENID;
+import static com.ruoyi.common.constant.Constants.TOKEN;
+import static com.ruoyi.common.constant.UserConstants.PWD;
+
+/**
+ * @author xh
+ * @Date 2022/7/14
+ */
+//@RestController
+@Slf4j
+@RestController
+@RequestMapping("/wx")
+public class WxMsgController {
+
+    /**
+     * 获取微信配置信息
+     */
+    @Autowired
+    private WxMsgService wxMsgService;
+
+    @Autowired
+    private SysLoginService loginService;
+
+
+
+    /**
+     * 测试接收微信官方通知
+     *
+     * @param request
+     * @return
+     */
+    @GetMapping(value = "/weChatToken", produces = {"application/json;charset=utf-8"})
+    @ResponseBody
+    public String notify(HttpServletRequest request) {
+        String token = "heart";
+        // 判断是否是Get请求
+        boolean isGet = request.getMethod().toLowerCase().equals("get");
+        if (isGet) {
+            // 微信加密签名
+            String signature = request.getParameter("signature");
+            // 时间戳
+            String timestamp = request.getParameter("timestamp");
+            // 随机数
+            String nonce = request.getParameter("nonce");
+            log.info("signature:{}, timestamp:{}, nonce:{}", signature, timestamp, nonce);
+            // 随机字符串
+            String echostr = request.getParameter("echostr");
+
+
+            // 1)将token、timestamp、nonce三个参数进行字典序排序
+            List<String> list = Arrays.asList(token, timestamp, nonce);
+            Collections.sort(list);
+            // 2)将三个参数字符串拼接成一个字符串进行sha1加密
+            StringBuilder stringBuilder = new StringBuilder();
+            for (String s : list){
+                stringBuilder.append(s);
+            }
+
+            try {
+                // 通过检验signature对请求进行校验,若校验成功则原样返回echostr,表示接入成功,否则接入失败
+                MessageDigest instance =
+                        MessageDigest.getInstance("sha1");
+                //使⽤sha1进⾏加密,获得byte数组
+                byte[] digest =
+                        instance.digest(stringBuilder.toString().getBytes());
+                StringBuilder sum = new StringBuilder();
+                for (byte b : digest) {
+                    sum.append(Integer.toHexString((b >> 4) & 15));
+                    sum.append(Integer.toHexString(b & 15));
+                }
+                // 3)开发者获得加密后的字符串可与 signature 对⽐,标识该请求来源于微信
+                if (!StringUtils.isEmpty(signature) &&
+                        signature.equals(sum.toString())) {
+                    return echostr;
+                }
+
+            } catch (Exception e) {
+                log.info("测试微信公众号的接口配置信息发生异常:", e);
+                return "系统异常!";
+            }
+        } else {
+            return "非法请求!疑似黑客攻击,列入黑名单";
+        }
+        return null;
+    }
+
+    /**
+     * 获取access_token,access_token是公众号的全局唯一接口调用凭据
+     */
+    @GetMapping("/get_wx_token")
+    @ResponseBody
+    public Map<String, Long> getWxToken() {
+        RestTemplate restTemplate = new RestTemplate();
+        Map<String, String> map = new HashMap<>();
+        map.put("AppId", WxMpPropertiesConfig.getAppId());
+        map.put("AppSecret", WxMpPropertiesConfig.getSecret());
+        // 调用微信公众号接口
+        ResponseEntity<String> forEntity = restTemplate.getForEntity("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={AppId}&secret={AppSecret}", String.class, map);
+        // 解析JSON
+        String body = forEntity.getBody();
+        log.info("发送token获得到的body:{}", body);
+        Gson gson = new Gson();
+        HashMap<String, Object> jsonObject = gson.fromJson(body, HashMap.class);
+        String accessToken = String.valueOf(jsonObject.get("access_token"));
+        Double expiresIn = Double.parseDouble(String.valueOf(jsonObject.get("expires_in")));//时效--7200s
+        return new HashMap<String, Long>() {{put(accessToken, expiresIn.longValue());}};
+    }
+
+
+
+    /**
+     * 获取微信用户code,并重定向获取用户openId
+     *
+     * @return
+     */
+    @GetMapping("/getOpenIdUrl")
+    @ResponseBody
+    public AjaxResult getOpenIdUrl() {
+        String url = WxMpPropertiesConfig.getUrl();
+        String backUrl = url + "/api/getUserOpenId";
+        String getOpenIdUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=" + backUrl + "&response_type=code&scope=snsapi_userinfo&state=1,0#wechat_redirect";
+        getOpenIdUrl = getOpenIdUrl.replace("APPID", WxMpPropertiesConfig.getAppId());
+        return AjaxResult.success(getOpenIdUrl);
+    }
+
+    @GetMapping("/wxlogin")
+    public String wxlogin(){
+        String url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + WxMpPropertiesConfig.getAppId() +
+                "&redirect_uri=" + WxMpPropertiesConfig.getUrl()+ "/api/getUserOpenId" +
+                "&response_type=code" +
+                "&scope=snsapi_userinfo" +
+                "&state=STATE#wechat_redirect";
+        return "redirect:"+url;
+    }
+
+    /**
+     * 根据用户openId创建账号
+     *
+     * @return
+     * @throws IOException
+     */
+    @GetMapping(value = "/getUserOpenId")
+    public AjaxResult getUserOpenId(String code){
+        SysUser user = wxMsgService.creatUser(code);
+        // 生成令牌
+        AjaxResult ajax = AjaxResult.success();
+        String token = "";
+        if (!StringUtils.isEmpty(user.getUserName())) {
+            token = loginService.login(user.getUserName(), PWD, "",
+                    "");
+        }
+
+        ajax.put(TOKEN, token);
+        ajax.put(OPENID, user.getOpenId());
+        ajax.put(TOKEN, token);
+        return ajax;
+    }
+
+    /**
+     * 根据用户openId创建账号
+     *
+     * @return
+     * @throws IOException
+     */
+    @GetMapping(value = "/gzhLogin")
+    public AjaxResult gzhLogin(String openId, String phone){
+        SysUser user = wxMsgService.gzhLogin(openId,phone);
+        // 生成令牌
+        AjaxResult ajax = AjaxResult.success();
+        String token = loginService.login(user.getUserName(), PWD, "",
+                "");
+        ajax.put(TOKEN, token);
+        ajax.put(OPENID, user.getOpenId());
+        return ajax;
+    }
+}

+ 6 - 0
ruoyi-common/pom.xml

@@ -119,6 +119,12 @@
             <artifactId>javax.servlet-api</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.github.binarywang</groupId>
+            <artifactId>weixin-java-mp</artifactId>
+            <version>4.5.0</version>
+        </dependency>
+
 
         <dependency>
             <groupId>org.springframework.boot</groupId>

+ 5 - 0
ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java

@@ -170,4 +170,9 @@ public class Constants
      */
     public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
             "org.springframework", "org.apache", "com.ruoyi.common.utils.file", "com.ruoyi.common.config", "com.ruoyi.generator" };
+
+    /**
+     * openId
+     */
+    public static final String OPENID = "openId";
 }

+ 4 - 1
ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java

@@ -74,7 +74,7 @@ public class UserConstants
      * 用户名长度限制
      */
     public static final int USERNAME_MIN_LENGTH = 2;
-    public static final int USERNAME_MAX_LENGTH = 20;
+    public static final int USERNAME_MAX_LENGTH = 100;
 
     /**
      * 密码长度限制
@@ -96,4 +96,7 @@ public class UserConstants
 
     /** 接单员工 */
     public final static String WORK_USER = "employee";
+
+    /** 默认密码 */
+    public final static String PWD = "1qaz!QAZ";
 }

+ 12 - 0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java

@@ -29,6 +29,10 @@ public class SysUser extends BaseEntity
     @Excel(name = "部门编号", type = Type.IMPORT)
     private Long deptId;
 
+    /** 微信唯一标识 */
+    private String openId;
+
+
     /** 用户账号 */
     @Excel(name = "登录名称")
     private String userName;
@@ -297,6 +301,14 @@ public class SysUser extends BaseEntity
         this.roleId = roleId;
     }
 
+    public String getOpenId() {
+        return openId;
+    }
+
+    public void setOpenId(String openId) {
+        this.openId = openId;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

+ 16 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/osSelect.java

@@ -0,0 +1,16 @@
+package com.ruoyi.common.utils;
+
+/**
+ * @author jiangxin
+ * @create 2022-01-19-16:40
+ */
+public class osSelect {
+
+    public static boolean isLinux() {
+        return System.getProperty("os.name").toLowerCase().contains("linux");
+    }
+
+    public static boolean isWindows() {
+        return System.getProperty("os.name").toLowerCase().contains("windows");
+    }
+}

+ 137 - 0
ruoyi-common/src/main/java/com/ruoyi/common/wxMessage/WeChatMessageSender.java

@@ -0,0 +1,137 @@
+package com.ruoyi.common.wxMessage;
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
+import com.google.gson.Gson;
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.http.HttpUtils;
+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.util.EntityUtils;
+import org.springframework.http.ResponseEntity;
+import org.springframework.http.converter.StringHttpMessageConverter;
+import org.springframework.web.client.RestTemplate;
+
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Objects;
+
+public class WeChatMessageSender {
+    private static final String TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET";
+    private static final String MESSAGE_URL = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=";
+    public static final String WX_GET_INFO_URL = "https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID&lang=LANG";
+    //通过code获取网站授权 access_token
+    private static final String WZ_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code";
+
+    // Step 1: 获取access_token
+    public static String getAccessToken() throws Exception {
+        //String url = TOKEN_URL.replace("{}", WxMpPropertiesConfig.getAppId()).replace("{}", WxMpPropertiesConfig.getSecret());
+        String url = TOKEN_URL.replace("APPID", "wxe91077cda5699d3b").replace("APPSECRET", "258749dd19cb6acc8bbc28ededbd7e97");
+        HttpGet request = new HttpGet(url);
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        String result = httpClient.execute(request, httpResponse ->
+                EntityUtils.toString(httpResponse.getEntity()));
+        // 解析JSON获取access_token,这里假设已经通过某种方式(如Jackson, Gson)解析
+        // 这里简单用String.split()模拟解析
+        String[] parts = result.split(",");
+        for (String part : parts) {
+            if (part.contains("access_token")) {
+                String[] tokenParts = part.split(":");
+                return tokenParts[1].trim().replace("\"", "");
+            }
+        }
+        return null;
+    }
+
+
+    // Step 1: 通过code获取网站授权 access_token (非公众号access_token)
+    public static HashMap<String, Object> getWzAccessToken(String code) throws Exception {
+        //String url = TOKEN_URL.replace("{}", WxMpPropertiesConfig.getAppId()).replace("{}", WxMpPropertiesConfig.getSecret());
+        String url = WZ_TOKEN_URL.replace("APPID", WxMpPropertiesConfig.getAppId()).replace("SECRET", WxMpPropertiesConfig.getSecret()).replace("CODE", code);
+        //获取用户openid
+        RestTemplate restTemplate = new RestTemplate();
+        //解决乱码,以utf-8编码格式获取,不加这个会乱码
+        restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
+        ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class);
+        // 解析JSON
+        String body = forEntity.getBody();
+        Gson gson = new Gson();
+        HashMap<String, Object> jsonObject = gson.fromJson(body, HashMap.class);
+        return jsonObject;
+    }
+
+    // Step 2: 发送消息
+    public static void sendMessage(Map<String,Object> mesgMap) throws Exception {
+        String accessToken = getAccessToken();
+
+        try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
+            String url = MESSAGE_URL + accessToken;
+            HttpPost httpPost = new HttpPost(url);
+            httpPost.setHeader("Content-Type", "application/json");
+            StringEntity entity = new StringEntity(JSONObject.toJSONString(mesgMap), StandardCharsets.UTF_8);
+            httpPost.setEntity(entity);
+
+            CloseableHttpResponse response = httpClient.execute(httpPost);
+            String responseBody = EntityUtils.toString(response.getEntity(), "UTF-8");
+            System.out.println(responseBody);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     *	获取用户昵称
+     */
+    public static Map<String,Object> getWxUserInfo(String code) throws Exception {
+        Map<String,Object> wxUserMap = new HashMap<>();
+        // 获取Access_Token
+        HashMap<String, Object> jsonObject = getWzAccessToken(code);
+        String openid = String.valueOf(jsonObject.get("openid"));
+        String accessToken = String.valueOf(jsonObject.get("access_token"));
+        String url = WX_GET_INFO_URL.replace("ACCESS_TOKEN", accessToken).replace("OPENID", openid).replace("LANG", "zh_CN");
+        RestTemplate restTemplate = new RestTemplate();
+        //解决乱码,以utf-8编码格式获取,不加这个会乱码
+        restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
+        ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class);
+        // 解析JSON
+        String body = forEntity.getBody();
+        Gson gson = new Gson();
+        wxUserMap = gson.fromJson(body, HashMap.class);
+        return wxUserMap;
+    }
+
+
+    public static void main(String[] args) throws Exception {
+        Map<String,Object> mesgMap = new HashMap<>();
+        mesgMap.put("touser", "oBUfy7KYW8z61QrBbJ5mwebvbfd8");
+        mesgMap.put("template_id", "aAtYCooyrG5I1j-ofeQuEye_71ZH5SXZnv-tNoC1BgU");
+        mesgMap.put("url", "https://zxygdhf.qs163.cn/work/pages/detail?id=17479811779881459");
+        Map<String,Object> dMap = new HashMap<>();
+        Map<String,Object> dMap1 = new HashMap<>();
+        dMap1.put("value","17479811779881459");
+        dMap.put("character_string1",dMap1);
+
+        Map<String,Object> dMap2 = new HashMap<>();
+        dMap2.put("value","张三");
+        dMap.put("thing7",dMap2);
+
+        Map<String,Object> dMap3 = new HashMap<>();
+        dMap3.put("value","18112341234");
+        dMap.put("phone_number8", dMap3);
+
+        Map<String,Object> dMap4 = new HashMap<>();
+        dMap4.put("value","2025-06-04 17:41:41");
+        dMap.put("time9",dMap4);
+
+        mesgMap.put("data",dMap);
+        WeChatMessageSender.sendMessage(mesgMap);
+        //WeChatMessageSender.getWxUserInfo("081dvf0w3zS4453z1G3w3UktlG3dvf0y");
+    }
+
+}

+ 95 - 0
ruoyi-common/src/main/java/com/ruoyi/common/wxMessage/WxMpPropertiesConfig.java

@@ -0,0 +1,95 @@
+package com.ruoyi.common.wxMessage;
+
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author xh
+ * @Date 2022/7/14
+ */
+
+@Component
+@ConfigurationProperties(prefix = "wx")
+public class WxMpPropertiesConfig {
+    /**
+     * 公众号appId
+     */
+    private static String appId;
+
+    /**
+     * 公众号appSecret
+     */
+    private static String secret;
+
+
+    /**
+     * 公众号token
+     */
+    private static String token;
+
+    /**
+     * 公众号aesKey
+     */
+    private static String aesKey;
+
+    /**
+     * 服务器地址
+     */
+    private static String url;
+
+    /**
+     * 前端服务器地址
+     */
+    private static String frontUrl;
+
+
+
+    public static String getAppId() {
+        return appId;
+    }
+
+    public void setAppId(String appId) {
+        this.appId = appId;
+    }
+
+    public static String getSecret() {
+        return secret;
+    }
+
+    public void setSecret(String secret) {
+        this.secret = secret;
+    }
+
+    public static String getToken() {
+        return token;
+    }
+
+    public void setToken(String token) {
+        this.token = token;
+    }
+
+    public static String getAesKey() {
+        return aesKey;
+    }
+
+    public void setAesKey(String aesKey) {
+        this.aesKey = aesKey;
+    }
+
+    public static String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public static String getFrontUrl() {
+        return frontUrl;
+    }
+
+    public void setFrontUrl(String frontUrl) {
+        this.frontUrl = frontUrl;
+    }
+}

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

@@ -111,7 +111,7 @@ public class SecurityConfig
             .authorizeHttpRequests((requests) -> {
                 permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll());
                 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
-                requests.antMatchers("/login", "/register", "/captchaImage","/work/info/dzgd/**").permitAll()
+                requests.antMatchers("/login", "/register", "/captchaImage","/work/info/dzgd/**","/wx/**").permitAll()
                     // 静态资源,可匿名访问
                     .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
                     .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()

+ 6 - 0
ruoyi-system/pom.xml

@@ -47,6 +47,12 @@
             <optional>true</optional>
         </dependency>
 
+        <dependency>
+            <groupId>com.github.binarywang</groupId>
+            <artifactId>weixin-java-mp</artifactId>
+            <version>4.5.0</version>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java

@@ -124,4 +124,6 @@ public interface SysUserMapper
      * @return 结果
      */
     public SysUser checkEmailUnique(String email);
+
+    SysUser selectUserByOpenId(String openid);
 }

+ 10 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/WxMsgService.java

@@ -0,0 +1,10 @@
+package com.ruoyi.system.service;
+
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.SysUser;
+
+public interface WxMsgService {
+    SysUser creatUser(String code);
+
+    SysUser gzhLogin(String openId, String phone);
+}

+ 104 - 33
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WorkOrderInfoServiceImpl.java

@@ -19,13 +19,11 @@ import com.ruoyi.common.core.domain.entity.SysRole;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.domain.model.LoginBody;
 import com.ruoyi.common.core.domain.model.LoginUser;
-import com.ruoyi.common.utils.DateUtils;
-import com.ruoyi.common.utils.SecurityUtils;
-import com.ruoyi.common.utils.ServletUtils;
-import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.*;
 import com.ruoyi.common.utils.base64.Base64DecodedMultipartFile;
 import com.ruoyi.common.utils.file.FileUploadUtils;
 import com.ruoyi.common.utils.file.FileUtils;
+import com.ruoyi.common.wxMessage.WeChatMessageSender;
 import com.ruoyi.system.domain.ChargeDetails;
 import com.ruoyi.system.domain.OperationRecord;
 import com.ruoyi.system.domain.WorkOrderFj;
@@ -125,8 +123,8 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
         workOrderInfo.setUserId(user.getUserId());
         workOrderInfo.setUserName(user.getUserName());
         //生成工单编号(时间戳+4位随机数)
-        workOrderInfo.setOrderId(DateUtils.getOrderId());
-        workOrderInfo.setCreateTime(DateUtils.getNowDate());
+        workOrderInfo.setOrderId(getOrderId());
+        workOrderInfo.setCreateTime(getNowDate());
         int i = workOrderInfoMapper.insertWorkOrderInfo(workOrderInfo);
         if (workOrderInfo.getWorkOrderFjXqList() != null && !workOrderInfo.getWorkOrderFjXqList().isEmpty()) {
             for (WorkOrderFj workOrderFj : workOrderInfo.getWorkOrderFjXqList()) {
@@ -137,7 +135,7 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
 
         OperationRecord operationRecord = new OperationRecord();
         operationRecord.setOrderId(workOrderInfo.getOrderId());
-        String type = dictDataMapper.selectDictLabel("service_progress", workOrderInfo.getType());
+        String type = dictDataMapper.selectDictLabel("work_order_type", workOrderInfo.getType());
         StringBuilder recod = new StringBuilder();
         recod.append(workOrderInfo.getUnitName()).append("发起了一个").append(type).append(",联系方式").append(workOrderInfo.getPhonenumber());
         operationRecord.setRecord(recod.toString());
@@ -151,6 +149,7 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
      * @param workOrderInfo 工单信息
      * @return 结果
      */
+    @SneakyThrows
     @Override
     public int updateWorkOrderInfo(WorkOrderInfo workOrderInfo) {
 
@@ -203,24 +202,26 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
             //操作记录
             OperationRecord operationRecord = new OperationRecord();
             operationRecord.setOrderId(workOrderInfo.getOrderId());
-            String type = dictDataMapper.selectDictLabel("service_progress", workOrderInfo.getType());
+            String type = dictDataMapper.selectDictLabel("work_order_type", workOrderInfo.getType());
             StringBuilder recod = new StringBuilder();
             recod.append(workOrderInfo.getUnitName()).append("的").append(type).append("已结束;客户暂无评价");
             operationRecord.setRecord(recod.toString());
             operationRecordService.insertOperationRecord(operationRecord);
+
         }
         if (THR.equals(workOrderInfo.getServiceProgress())) {
             WorkOrderInfo orderInfo = workOrderInfoMapper.selectWorkOrderInfoByOrderId(workOrderInfo.getOrderId());
             //操作记录
             OperationRecord operationRecord = new OperationRecord();
             operationRecord.setOrderId(workOrderInfo.getOrderId());
-            String type = dictDataMapper.selectDictLabel("service_progress", orderInfo.getType());
+            String type = dictDataMapper.selectDictLabel("work_order_type", orderInfo.getType());
             StringBuilder recod = new StringBuilder();
             recod.append(orderInfo.getUnitName()).append("的").append(type).append("已结束;客户评价:").append(workOrderInfo.getEvaluationContent());
             operationRecord.setRecord(recod.toString());
             operationRecordService.insertOperationRecord(operationRecord);
+
         }
-        workOrderInfo.setUpdateTime(DateUtils.getNowDate());
+        workOrderInfo.setUpdateTime(getNowDate());
         return workOrderInfoMapper.updateWorkOrderInfo(workOrderInfo);
     }
 
@@ -246,19 +247,20 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
         return workOrderInfoMapper.deleteWorkOrderInfoByOrderId(orderId);
     }
 
+    @SneakyThrows
     @Override
     public int jd(WorkOrderInfo workOrderInfo) {
         //操作记录
         WorkOrderInfo orderInfo = workOrderInfoMapper.selectWorkOrderInfoByOrderId(workOrderInfo.getOrderId());
         OperationRecord operationRecord = new OperationRecord();
         operationRecord.setOrderId(workOrderInfo.getOrderId());
-        String type = dictDataMapper.selectDictLabel("service_progress", workOrderInfo.getType());
+        String type = dictDataMapper.selectDictLabel("work_order_type", workOrderInfo.getType());
         StringBuilder recod = new StringBuilder();
         recod.append(workOrderInfo.getResponsibleName()).append("接下了").append(orderInfo.getUnitName()).append("的");
         recod.append(type).append("工单:工单编号").append(orderInfo.getOrderId());
 
         workOrderInfo.setServiceProgress(ONE);
-        workOrderInfo.setTakeTime(DateUtils.getNowDate());
+        workOrderInfo.setTakeTime(getNowDate());
         workOrderInfo.setAgency(ONE);
 
         //自主接单
@@ -274,9 +276,39 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
         }
         operationRecord.setRecord(recod.toString());
         operationRecordService.insertOperationRecord(operationRecord);
-        return workOrderInfoMapper.updateWorkOrderInfo(workOrderInfo);
+        int i = workOrderInfoMapper.updateWorkOrderInfo(workOrderInfo);
+
+        //公众号推送
+        //查询创建人信息
+        SysUser user = userMapper.selectUserById(orderInfo.getUserId());
+        Map<String,Object> mesgMap = new HashMap<>();
+        mesgMap.put("touser", user.getOpenId());
+        mesgMap.put("template_id", "aAtYCooyrG5I1j-ofeQuEye_71ZH5SXZnv-tNoC1BgU");
+        mesgMap.put("url", "https://zxygdhf.qs163.cn/work/pages/detail?id="+orderInfo.getOrderId());
+        Map<String,Object> dMap = new HashMap<>();
+
+        Map<String,Object> dMap1 = new HashMap<>();
+        dMap1.put("value",orderInfo.getOrderId());
+        dMap.put("character_string1",dMap1);
+
+        Map<String,Object> dMap2 = new HashMap<>();
+        dMap2.put("value",orderInfo.getResponsibleName());
+        dMap.put("thing7",dMap2);
+
+        Map<String,Object> dMap3 = new HashMap<>();
+        dMap3.put("value",orderInfo.getResponsiblePhone());
+        dMap.put("phone_number8",dMap3);
+
+        Map<String,Object> dMap4 = new HashMap<>();
+        dMap4.put("value",DateUtils.getTime());
+        dMap.put("time9",dMap4);
+
+        mesgMap.put("data",dMap);
+        WeChatMessageSender.sendMessage(mesgMap);
+        return i;
     }
 
+    @SneakyThrows
     @Override
     public AjaxResult dzgd(String orderId) {
         //查询工单信息
@@ -312,7 +344,7 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
         finalMap.put("rmb", workOrderInfo.getTotalCost());
         finalMap.put("bz", workOrderInfo.getRemark());
         finalMap.put("lxfs", workOrderInfo.getPhonenumber());
-        finalMap.put("rq", DateUtils.getDate());
+        finalMap.put("rq", getDate());
         finalMap.put("bz", workOrderInfo.getRemark());
         finalMap.put("qm", "{{@qm}}");
 
@@ -349,13 +381,23 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
 
 
         // 从网络url 下载word模板到指定文件夹
-        File wordTemplate = new File("D:\\ruoyi\\uploadPath\\gongdan\\muban\\工单模板.docx");
+        File wordTemplate = null;
+        if (osSelect.isWindows()){
+            wordTemplate = new File("D:\\ruoyi\\uploadPath\\gongdan\\muban\\工单模板.docx");
+        }else if (osSelect.isLinux()){
+            wordTemplate = new File("/home/ruoyi/uploadPath/gongdan/muban/工单模板.docx");
+        }
+
         // 此处使用了poi-tl的<表格行循环插件>,此处一定要进行参数bind,方便word模板参数替换
         LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
         Configure build = Configure.builder().bind(policy, "workList").build();
         XWPFTemplate render = XWPFTemplate.compile(wordTemplate, build).render(finalMap);
         // 此处是利用File,直接在本地创建文件,将参数替换后的文件流写入到该文件,word就是最终的结果
-        String fileName = workOrderInfo.getUnitName() + "-" + workOrderInfo.getProjectName() + "项目工单.docx";
+        String projectName = "";
+        if(StringUtils.isNotBlank(workOrderInfo.getProjectName())){
+            projectName = workOrderInfo.getProjectName();
+        }
+        String fileName = workOrderInfo.getUnitName() + "-" + projectName + "项目工单.docx";
         String templatePath = "/profile/upload/" + fileName;
         String path = RuoYiConfig.getUploadPath() + "/" + fileName;
         ;
@@ -374,6 +416,31 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
         //删除之前生成的文件
         workOrderFjMapper.deleteWorkOrderFj(workOrderFj);
         workOrderFjMapper.insertWorkOrderFj(workOrderFj);
+
+        //订单完成时向客户发送消息
+        //查询创建人信息
+        SysUser user = userMapper.selectUserById(workOrderInfo.getUserId());
+        Map<String,Object> mesgMap = new HashMap<>();
+        mesgMap.put("touser", user.getOpenId());
+        mesgMap.put("template_id", "0ljHkgAiXXUg6bSlKGn4shxrSPiOtXDcWKAmbN-2tRc");
+        mesgMap.put("url", "https://zxygdhf.qs163.cn/work/pages/detail?id="+workOrderInfo.getOrderId());
+        Map<String,Object> dMap = new HashMap<>();
+
+        Map<String,Object> dMap1 = new HashMap<>();
+        dMap1.put("value",workOrderInfo.getOrderId());
+        dMap.put("character_string1",dMap1);
+
+        Map<String,Object> dMap2 = new HashMap<>();
+        dMap2.put("value",workOrderInfo.getProjectName());
+        dMap.put("thing2",dMap2);
+
+        Map<String,Object> dMap3 = new HashMap<>();
+        dMap3.put("value",DateUtils.getTime());
+        dMap.put("time3",dMap3);
+
+        mesgMap.put("data",dMap);
+        WeChatMessageSender.sendMessage(mesgMap);
+
         return AjaxResult.success("成功", templatePath);
     }
 
@@ -448,7 +515,7 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
         //操作记录
         OperationRecord operationRecord = new OperationRecord();
         operationRecord.setOrderId(workOrderInfo.getOrderId());
-        String type = dictDataMapper.selectDictLabel("service_progress", workOrderInfo.getType());
+        String type = dictDataMapper.selectDictLabel("work_order_type", workOrderInfo.getType());
         StringBuilder recod = new StringBuilder();
         recod.append(workOrderInfo.getUnitName()).append("的").append(type).append("已结束;客户暂无评价");
         operationRecord.setRecord(recod.toString());
@@ -470,9 +537,9 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
         int szs = 0;
         String zz = "0%";
         //获取当前月
-        String month = DateUtils.dateTimeNow(YYYY_MM_DD);
+        String month = dateTimeNow(YYYY_MM_DD);
         //获取上个月
-        String lastMonth = DateUtils.lastMonth();
+        String lastMonth = lastMonth();
         //本月单量
         List<WorkOrderInfo> workOrderInfoList = workOrderInfoMapper.selectWorkOrderInfoListBymonth(month);
         //上个月单量
@@ -524,7 +591,7 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
         int sjfw = 0;
         int qtfw = 0;
         //获取当前月
-        String month = DateUtils.dateTimeNow(YYYY_MM_DD);
+        String month = dateTimeNow(YYYY_MM_DD);
         //本月单量
         List<WorkOrderInfo> workOrderInfoList = workOrderInfoMapper.selectWorkOrderInfoListBymonth(month);
         if (workOrderInfoList != null && !workOrderInfoList.isEmpty()) {
@@ -564,9 +631,9 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
     public AjaxResult bj() {
         Map<String, Object> map = new HashMap<>();
         //获取当前月
-        String month = DateUtils.dateTimeNow(YYYY_MM_DD);
+        String month = dateTimeNow(YYYY_MM_DD);
         //获取上个月
-        String lastMonth = DateUtils.lastMonth()+"-01";
+        String lastMonth = lastMonth()+"-01";
         //本月单量
         List<WorkOrderInfo> workOrderInfoList = workOrderInfoMapper.selectWorkOrderInfoListBymonth(month);
         //上个月单量
@@ -666,8 +733,8 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
         String zzbfb = "0%";
         String zpbfb = "0%";
         //获取季度的开始时间和结束时间
-        String startDate = DateUtils.startQuarterly() + " 00:00:00";
-        String endDate = DateUtils.endQuarterly() + " 23:59:59";
+        String startDate = startQuarterly() + " 00:00:00";
+        String endDate = endQuarterly() + " 23:59:59";
         SysUser user = SecurityUtils.getLoginUser().getUser();
         List<WorkOrderInfo> workOrderInfoList = workOrderInfoMapper.selectWorkOrderInfoListByTime(startDate, endDate, user.getUserId());
         if (workOrderInfoList != null && !workOrderInfoList.isEmpty()) {
@@ -717,7 +784,7 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
     @Override
     public AjaxResult monthPx(String time) {
         if (StringUtils.isEmpty(time)) {
-            time = DateUtils.dateTimeNow(YYYY_MM_DD);
+            time = dateTimeNow(YYYY_MM_DD);
         }else{
             time = time +"-01";
         }
@@ -758,7 +825,7 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
     @Override
     public AjaxResult yearPx(String time) {
         if (StringUtils.isEmpty(time)) {
-            time = DateUtils.dateTimeNow(YYYY_MM_DD);
+            time = dateTimeNow(YYYY_MM_DD);
         }else{
             time = time +"-01-01";
         }
@@ -788,7 +855,11 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
             SysUser sysUser = userMapper.selectUserById(entries.get(i).getKey());
             mapPx.put("xh", i + 1);
             mapPx.put("name", sysUser.getNickName());
-            mapPx.put("deptName", sysUser.getDept().getDeptName());
+            String deptName = "";
+            if (sysUser.getDept() != null) {
+                deptName = sysUser.getDept().getDeptName();
+            }
+            mapPx.put("deptName", deptName);
             mapPx.put("num", entries.get(i).getValue());
             listMap.add(mapPx);
         }
@@ -799,7 +870,7 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
     @Override
     public AjaxResult yearFwlx(String time) {
         if (StringUtils.isEmpty(time)) {
-            time = DateUtils.dateTimeNow(YYYY_MM_DD);
+            time = dateTimeNow(YYYY_MM_DD);
         }else{
             time = time +"-01-01";
         }
@@ -863,7 +934,7 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
     @Override
     public AjaxResult yearLc(String time) {
         if (StringUtils.isEmpty(time)) {
-            time = DateUtils.dateTimeNow(YYYY_MM_DD);
+            time = dateTimeNow(YYYY_MM_DD);
         }else{
             time = time +"-01-01";
         }
@@ -907,8 +978,8 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
         Map<String, Object> map = new HashMap<>();
         String year = time;
         if (StringUtils.isEmpty(time)) {
-            time = DateUtils.dateTimeNow(YYYY_MM_DD);
-            year = DateUtils.dateTimeNow(YYYY);
+            time = dateTimeNow(YYYY_MM_DD);
+            year = dateTimeNow(YYYY);
         }else{
             time = time +"-01-01";
         }
@@ -939,7 +1010,7 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
             int num = 0;
             if (workOrderInfoList != null && !workOrderInfoList.isEmpty()) {
                 for (WorkOrderInfo workOrderInfo : workOrderInfoList) {
-                    if (DateUtils.dateTime(workOrderInfo.getCreateTime()).contains(month)) {
+                    if (dateTime(workOrderInfo.getCreateTime()).contains(month)) {
                         num++;
                     }
                 }
@@ -955,7 +1026,7 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService {
     public AjaxResult deptLc(String time) {
 
         if (StringUtils.isEmpty(time)) {
-            time = DateUtils.dateTimeNow(YYYY_MM_DD);
+            time = dateTimeNow(YYYY_MM_DD);
         }else{
             time = time +"-01-01";
         }

+ 88 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WxMsgServiceImpl.java

@@ -0,0 +1,88 @@
+package com.ruoyi.system.service.impl;
+
+import com.google.gson.Gson;
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.common.constant.HttpStatus;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.wxMessage.WeChatMessageSender;
+import com.ruoyi.common.wxMessage.WxMpPropertiesConfig;
+import com.ruoyi.system.mapper.SysUserMapper;
+import com.ruoyi.system.service.ISysUserService;
+import com.ruoyi.system.service.WxMsgService;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.http.converter.StringHttpMessageConverter;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
+import static com.ruoyi.common.constant.UserConstants.PWD;
+
+@Slf4j
+@Service
+public class WxMsgServiceImpl implements WxMsgService {
+
+    @Autowired
+    private ISysUserService userService;
+
+    @Autowired
+    private SysUserMapper userMapper;
+
+    @Autowired
+    private RedisCache redisCache;
+
+    @SneakyThrows
+    @Override
+    public SysUser creatUser(String code) {
+        //获取code
+        log.info("获取到微信授权后:code:{}", code);
+        //获取用户openid
+        Map<String, Object> wxUserInfo = WeChatMessageSender.getWxUserInfo(code);
+        String openid = String.valueOf(wxUserInfo.get("openid"));
+        if("null".equals(openid)){
+            throw new ServiceException("授权码错误,请重新授权");
+        }
+        //将数据存入redis
+        redisCache.setCacheObject(openid, wxUserInfo);
+        //查询openid是否在数据库
+        SysUser sysUser = userMapper.selectUserByOpenId(openid);
+        if (sysUser == null) {
+            sysUser = new SysUser();
+            sysUser.setOpenId(openid);
+        }
+        return sysUser;
+    }
+
+    @Override
+    public SysUser gzhLogin(String openId, String phone) {
+        //查询账号是否在数据库
+        SysUser sysUser = userMapper.selectUserByUserName(phone);
+        if (sysUser == null) {
+            //创建账号
+            //从redis中取出数据
+            Map<String, Object> wxUserInfo = redisCache.getCacheObject(openId);
+            sysUser = new SysUser();
+            sysUser.setUserName(phone);
+            sysUser.setPhonenumber(phone);
+            sysUser.setNickName(String.valueOf(wxUserInfo.get("nickname")));
+            sysUser.setAvatar(String.valueOf(wxUserInfo.get("headimgurl")));
+            sysUser.setOpenId(openId);
+            sysUser.setPassword(SecurityUtils.encryptPassword(PWD));
+            Long[] roleIds = new Long[1];
+            roleIds[0] = 102L;
+            sysUser.setRoleIds(roleIds);
+            userService.insertUser(sysUser);
+        }
+        return sysUser;
+    }
+}

+ 14 - 6
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <resultMap type="SysUser" id="SysUserResult">
         <id     property="userId"       column="user_id"      />
         <result property="deptId"       column="dept_id"      />
+		<result property="openId"     column="open_id"    />
         <result property="userName"     column="user_name"    />
         <result property="nickName"     column="nick_name"    />
         <result property="email"        column="email"        />
@@ -47,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 	
 	<sql id="selectUserVo">
-        select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, 
+        select u.user_id, u.dept_id,u.open_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
         d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
         r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
         from sys_user u
@@ -57,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </sql>
     
     <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
-		select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
+		select u.user_id, u.dept_id,u.open_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
 		left join sys_dept d on u.dept_id = d.dept_id
 		where u.del_flag = '0'
 		<if test="userId != null and userId != 0">
@@ -86,7 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	</select>
 	
 	<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
-	    select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
+	    select distinct u.user_id, u.dept_id,u.open_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
 	    from sys_user u
 			 left join sys_dept d on u.dept_id = d.dept_id
 			 left join sys_user_role ur on u.user_id = ur.user_id
@@ -103,7 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	</select>
 	
 	<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
-	    select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
+	    select distinct u.user_id, u.dept_id,u.open_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
 	    from sys_user u
 			 left join sys_dept d on u.dept_id = d.dept_id
 			 left join sys_user_role ur on u.user_id = ur.user_id
@@ -127,7 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	
 	<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
 		<include refid="selectUserVo"/>
-		where u.user_id = #{userId}
+		where u.user_id = #{userId} and u.del_flag = '0'
 	</select>
 	
 	<select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
@@ -141,11 +142,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
 		select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
 	</select>
-	
+
+	<select id="selectUserByOpenId" parameterType="String" resultMap="SysUserResult">
+		select  user_id, dept_id,open_id, user_name, nick_name, email, phonenumber, status, create_time from sys_user where open_id = #{openid} and del_flag = '0' limit 1
+	</select>
+
 	<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
  		insert into sys_user(
  			<if test="userId != null and userId != 0">user_id,</if>
  			<if test="deptId != null and deptId != 0">dept_id,</if>
+			<if test="openId != null and openId != ''">open_id,</if>
  			<if test="userName != null and userName != ''">user_name,</if>
  			<if test="nickName != null and nickName != ''">nick_name,</if>
  			<if test="email != null and email != ''">email,</if>
@@ -160,6 +166,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  		)values(
  			<if test="userId != null and userId != ''">#{userId},</if>
  			<if test="deptId != null and deptId != ''">#{deptId},</if>
+			<if test="openId != null and openId != ''">#{openId},</if>
  			<if test="userName != null and userName != ''">#{userName},</if>
  			<if test="nickName != null and nickName != ''">#{nickName},</if>
  			<if test="email != null and email != ''">#{email},</if>
@@ -178,6 +185,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  		update sys_user
  		<set>
  			<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
+			<if test="openId != null and openId != ''">open_id = #{openId},</if>
  			<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
  			<if test="email != null ">email = #{email},</if>
  			<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>

+ 2 - 2
ruoyi-system/src/main/resources/mapper/system/WorkOrderInfoMapper.xml

@@ -67,7 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="lon != null  and lon != ''"> and lon = #{lon}</if>
             <if test="lat != null  and lat != ''"> and lat = #{lat}</if>
             <if test="personName != null  and personName != ''"> and person_name like concat('%', #{personName}, '%')</if>
-            <if test="phonenumber != null  and phonenumber != ''"> and phonenumber = #{phonenumber}</if>
+            <if test="phonenumber != null  and phonenumber != ''"> and phonenumber like concat('%', #{phonenumber}, '%')</if>
             <if test="sex != null  and sex != ''"> and sex = #{sex}</if>
             <if test="type != null  and type != ''"> and type = #{type}</if>
             <if test="demand != null  and demand != ''"> and demand = #{demand}</if>
@@ -80,7 +80,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="agency != null  and agency != ''"> and agency = #{agency}</if>
             <if test="responsibleId != null "> and responsible_id = #{responsibleId}</if>
             <if test="responsibleName != null  and responsibleName != ''"> and responsible_name like concat('%', #{responsibleName}, '%')</if>
-            <if test="responsiblePhone != null  and responsiblePhone != ''"> and responsible_phone = #{responsiblePhone}</if>
+            <if test="responsiblePhone != null  and responsiblePhone != ''"> and responsible_phone = #like concat('%', #{responsiblePhone}, '%')</if>
             <if test="projectName != null  and projectName != ''"> and project_name like concat('%', #{projectName}, '%')</if>
             <if test="shelfLife != null  and shelfLife != ''"> and shelf_life = #{shelfLife}</if>
             <if test="isCharge != null  and isCharge != ''"> and is_charge = #{isCharge}</if>