xuhy
2024-08-19 8e5cffe7e8716272282c0313c5b3cb18700dbb89
策略詳情修改
3个文件已修改
3个文件已添加
333 ■■■■■ 已修改文件
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/TAccountingStrategyVO.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/MD5Util.java 131 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/MsgUtil.java 124 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/req/SubmitTempletReq.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TAccountingStrategyController.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/TAccountingStrategyVO.java
@@ -16,4 +16,11 @@
    @ApiModelProperty(value = "计费策略明细集合")
    private List<TAccountingStrategyDetail> accountingStrategyDetailList;
    @ApiModelProperty(value = "一級审核人员")
    private String firstUserName;
    @ApiModelProperty(value = "二級审核人员")
    private String twoUserName;
}
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/MD5Util.java
New file
@@ -0,0 +1,131 @@
package com.ruoyi.common.core.utils;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5Util {
 /**
     * 给指定字符串按照md5算法去加密
     *
     * @param psd 需要加密的密码   加盐处理
     *
     * @return md5后的字符串
     */
    public static String encoder(String psd) {
        try {
            //加盐处理
            psd = psd + "mobilesafe";
            //1,指定加密算法类型
            MessageDigest digest = MessageDigest.getInstance("MD5");
            //2,将需要加密的字符串中转换成byte类型的数组,然后进行随机哈希过程
            byte[] bs = digest.digest(psd.getBytes());
//          System.out.println(bs.length);
            //3,循环遍历bs,然后让其生成32位字符串,固定写法
            //4,拼接字符串过程
            StringBuffer stringBuffer = new StringBuffer();
            for (byte b : bs) {
                int i = b & 0xff;
                //int类型的i需要转换成16机制字符
                String hexString = Integer.toHexString(i);
//              System.out.println(hexString);
                if (hexString.length() < 2) {
                    hexString = "0" + hexString;
                }
                stringBuffer.append(hexString);
            }
            //5,打印测试
            System.out.println(stringBuffer.toString());
            return stringBuffer.toString();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return "";
    }
    /**
     * MD5加密字符串
     *
     * @param str
     * @return
     */
    public static String getMD5(String str) {
        if (StringUtils.isNotEmpty(str)) {
            try {
                MessageDigest md = MessageDigest.getInstance("MD5");
                md.update(str.getBytes());
                byte b[] = md.digest();
                int i;
                StringBuffer buf = new StringBuffer("");
                for (int offset = 0; offset < b.length; offset++) {
                    i = b[offset];
                    if (i < 0)
                        i += 256;
                    if (i < 16)
                        buf.append("0");
                    buf.append(Integer.toHexString(i));
                }
                //32位加密(小写)
            return buf.toString();
            //32位加密(大写)
            //return buf.toString().toUpperCase();
            // 16位的加密(小写)
            //return buf.toString().substring(8, 24);
            // 16位的加密(大写)
            //return buf.toString().substring(8, 24).toUpperCase();
            } catch (NoSuchAlgorithmException e) {
                e.printStackTrace();
            }
        }
        return "";
    }
    /**
     * 获取32位大写
     *
     * @param str
     * @return
     */
    public static String getMD5_32_upper(String str) {
        if (StringUtils.isNotEmpty(str))
            return getMD5(str).toUpperCase();
        return "";
    }
    /**
     * 获取32位小写
     *
     * @param str
     * @return
     */
    public static String getMD5_32_lower(String str) {
        if (StringUtils.isNotEmpty(str))
            return getMD5(str).toLowerCase();
        return "";
    }
    /**
     * 获取16位大写
     *
     * @param str
     * @return
     */
    public static String getMD5_16_upper(String str) {
        if (StringUtils.isNotEmpty(str))
            return getMD5(str).substring(8, 24).toUpperCase();
        return "";
    }
    /**
     * 获取16位小写
     *
     * @param str
     * @return
     */
    public static String getMD5_16_lower(String str) {
        if (StringUtils.isNotEmpty(str))
            return getMD5(str).substring(8, 24).toLowerCase();
        return "";
    }
}
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/MsgUtil.java
New file
@@ -0,0 +1,124 @@
package com.ruoyi.common.core.utils;
import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.core.utils.req.SubmitTempletReq;
import org.apache.commons.codec.binary.Base64;
import java.util.concurrent.ThreadLocalRandom;
public class MsgUtil {
    public final static String ecName= "四川明星新能源科技有限公司";
    public final static String secretKey= "MX_xny2023?9";
    public final static String sign= "1PUAVuY2b";
    /**
     * 更换手机号短信验证码
     * @param phone
     * @param code
     * @param templateId
     * @return
     */
    public static String codeMsg(String apId,String phone,String code,String templateId){
        SubmitTempletReq submitReq = new SubmitTempletReq();
        String[] paramss = {code};
        submitReq.setApId(apId);
        submitReq.setEcName(ecName);
        submitReq.setSecretKey(secretKey);
        submitReq.setParams(JSON.toJSONString(paramss));
        submitReq.setMobiles(phone);
        submitReq.setAddSerial("");
        submitReq.setSign(sign);
        submitReq.setTemplateId(templateId);
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append(submitReq.getEcName());
        stringBuffer.append(submitReq.getApId());
        stringBuffer.append(submitReq.getSecretKey());
        stringBuffer.append(submitReq.getTemplateId());
        stringBuffer.append(submitReq.getMobiles());
        stringBuffer.append(submitReq.getParams());
        stringBuffer.append(submitReq.getSign());
        stringBuffer.append(submitReq.getAddSerial());
        submitReq.setMac(MD5Util.getMD5(stringBuffer.toString()));
        String reqText = JSON.toJSONString(submitReq);
        //加密
        String encode = Base64.encodeBase64String(reqText.getBytes());
        System.err.println(encode);
        return encode;
    }
    /**
     * 审批流程短信
     * @param phone
     * @param name
     * @param work
     * @param templateId
     * @return
     */
    public static String auditMsg(String apId,String phone,String name,String work,String templateId){
        SubmitTempletReq submitReq = new SubmitTempletReq();
        // 判断工程名称长度
//        if(work.length()<=10){
//            String[] paramss = {name,work};
//            submitReq.setParams(JSON.toJSONString(paramss));
//            submitReq.setTemplateId("1ebcb36e532742ed8fd7b998a8222aab");
//        }else if (work.length()<=20){
//            String work1 = work.substring(0,10);
//            String work2 = work.substring(10);
//            String[] paramss = {name,work1,work2};
//            submitReq.setParams(JSON.toJSONString(paramss));
//            submitReq.setTemplateId("1c9e6cbddec649b1bdfa6830448df8ad");
//        }else if (work.length()<=30){
//            String work1 = work.substring(0,10);
//            String work2 = work.substring(10,20);
//            String work3 = work.substring(20);
//            String[] paramss = {name,work1,work2,work3};
//            submitReq.setParams(JSON.toJSONString(paramss));
//            submitReq.setTemplateId("91960e43e51446d0b3789129580f5bf8");
//        }else {
//            String work1 = work.substring(0, 10);
//            String work2 = work.substring(10, 20);
//            String work3 = work.substring(20, 30);
//            String work4 = work.substring(30);
//            String[] paramss = {name, work1, work2, work3, work4};
//            submitReq.setParams(JSON.toJSONString(paramss));
//            submitReq.setTemplateId("279dd31f0565494284ee62694ae3e326");
//        }
        String[] paramss = {name};
        submitReq.setParams(JSON.toJSONString(paramss));
        submitReq.setTemplateId("32b209c0096c48d7add8bafb290083dc");
        submitReq.setApId(apId);
        submitReq.setEcName(ecName);
        submitReq.setSecretKey(secretKey);
        submitReq.setMobiles(phone);
        submitReq.setAddSerial("");
        submitReq.setSign(sign);
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append(submitReq.getEcName());
        stringBuffer.append(submitReq.getApId());
        stringBuffer.append(submitReq.getSecretKey());
        stringBuffer.append(submitReq.getTemplateId());
        stringBuffer.append(submitReq.getMobiles());
        stringBuffer.append(submitReq.getParams());
        stringBuffer.append(submitReq.getSign());
        stringBuffer.append(submitReq.getAddSerial());
        submitReq.setMac(MD5Util.getMD5(stringBuffer.toString()));
        String reqText = JSON.toJSONString(submitReq);
        //加密
        String encode = Base64.encodeBase64String(reqText.getBytes());
        System.err.println(encode);
        return encode;
    }
    /**
     * 生成验证码
     * @return
     */
    public static String createCode(){
        return String.valueOf(ThreadLocalRandom.current().nextInt(100000, 999999));
    }
}
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/req/SubmitTempletReq.java
New file
@@ -0,0 +1,47 @@
package com.ruoyi.common.core.utils.req;
import lombok.Data;
import java.io.Serializable;
@Data
public class SubmitTempletReq implements Serializable {
    /**
     * 企业名称
     */
    private String ecName;
    /**
     * 接口账号用户名
     */
    private String apId;
    /**
     * 密码
     */
    private String secretKey;
    /**
     * 模板ID。在云MAS平台创建模板,路径:『短信』→『模板短信』→『模板管理』,创建后提交审核,审核通过将获得模板ID。
     */
    private String templateId;
    /**
     * 收信手机号码。英文逗号分隔,每批次限5000个号码,例:“13800138000,13800138001,13800138002”。
     */
    private String mobiles;
    /**
     * 模板变量。格式:[“param1”,“param2”],无变量模板填[""]
     */
    private String params;
    /**
     * 签名
     */
    private String sign;
    /**
     * 扩展码。依据开户时申请的服务代码匹配类型而定,如为精确匹配,此项填写空字符串("");如为模糊匹配,此项可填写空字符串或自定义的扩展码,注:服务代码加扩展码总长度不能超过20位。
     */
    private String addSerial;
    /**
     * 参数校验序列,生成方法:将ecName、apId、secretKey、templateId、mobiles、params、sign、addSerial按序拼接(无间隔符),通过MD5(32位小写)计算出的值。
     */
    private String mac;
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java
@@ -86,12 +86,6 @@
    private ExchangeOrderClient exchangeOrderClient;
    @Autowired
    private TokenService tokenService;
    @Autowired
    private RedisService redisService;
    @Autowired
    private WeixinProperties wxConfig;
    @Autowired
    private RestTemplate wxRestTemplate;
    @Resource
    private  TAppUserSignService signService;
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TAccountingStrategyController.java
@@ -4,6 +4,7 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.chargingPile.api.dto.TAccountingStrategyDTO;
import com.ruoyi.chargingPile.api.model.*;
import com.ruoyi.chargingPile.api.query.TAccountingStrategyQuery;
@@ -20,8 +21,10 @@
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.log.enums.OperatorType;
import com.ruoyi.system.api.feignClient.SysUserClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -51,7 +54,8 @@
    private TChargingPileService chargingPileService;
    @Autowired
    private ISiteService siteService;
    @Autowired
    private SysUserClient sysUserClient;
    @Resource
    private TokenService tokenService;
@@ -120,8 +124,16 @@
     */
    @ApiOperation(tags = {"后台-计费策略", "管理后台-站点管理"},value = "查看计费策略详情")
    @GetMapping(value = "/getDetailById")
    public AjaxResult<TAccountingStrategy> getDetailById(@RequestParam("id") Integer id) {
        return AjaxResult.ok(accountingStrategyService.getById(id));
    public AjaxResult<TAccountingStrategyVO> getDetailById(@RequestParam("id") Integer id) {
        TAccountingStrategy accountingStrategy = accountingStrategyService.getById(id);
        TAccountingStrategyVO accountingStrategyVO = new TAccountingStrategyVO();
        BeanUtils.copyProperties(accountingStrategy,accountingStrategyVO);
        // 查询用户信息
        String firstUserName = sysUserClient.getSysUser(accountingStrategy.getFirstUserId()).getData().getNickName();
        String twoUserName = sysUserClient.getSysUser(accountingStrategy.getTwoUserId()).getData().getNickName();
        accountingStrategyVO.setFirstUserName(firstUserName);
        accountingStrategyVO.setTwoUserName(twoUserName);
        return AjaxResult.ok(accountingStrategyVO);
    }
    /**