<p>//2.批量修改具体规则信息(同时生成对应语音包)
@PostMapping(&quot;/updateSpecificRegulars&quot;)
public Result<Object> updateSpecificRegulars(@RequestBody Map&lt;String, Object&gt; params, HttpServletRequest request) {</p>
<pre><code>//权限验证
String token = (String) request.getAttribute(&quot;claims_admin&quot;);
if (token == null || &quot;&quot;.equals(token)) {
    throw new RuntimeException(&quot;权限不足!&quot;);
}

log.info(&quot;updateSpecificRegulars的请求报文:&quot; + params);

JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(params));
JSONArray jsonArray = jsonObject.getJSONArray(&quot;specificRegular&quot;);
List&lt;SpecificRegular&gt; specificRegulars = JSONObject.parseArray(jsonArray.toJSONString(), SpecificRegular.class);//集合(前端传递的要修改的对象集合)

String phone = (String) params.get(&quot;phone&quot;);
if (!StringUtils.hasText(phone)) {
    log.error(&quot;phone为空!&quot;);
    return new Result&lt;&gt;(ResultCode.FAIL);
}
String userCode = (String) params.get(&quot;code&quot;);
if (!StringUtils.hasText(userCode)) {
    log.error(&quot;userCode为空!&quot;);
    return new Result&lt;&gt;(ResultCode.FAIL);
}

String specificRegularUpdate_uuid = redisTemplate.opsForValue().get(&quot;specificRegularUpdate_uuid&quot; + phone);
String myCode = redisTemplate.opsForValue().get(&quot;sRegularUpdate_&quot; + specificRegularUpdate_uuid + phone);

if (!StringUtils.hasText(myCode)) {
    log.error(&quot;myCode为空!&quot;);
    return new Result&lt;&gt;(ResultCode.FAIL);
}

if (!userCode.equals(myCode)) {
    log.error(&quot;验证码错误!&quot;);
    return new Result&lt;&gt;(ResultCode.CODE_FALSE);
}

log.info(&quot;验证码正确!&quot;);

//判断集合不为空
if (!CollectionUtils.isEmpty(specificRegulars)) {

    List&lt;SpecificRegular&gt; specificRegularList = new ArrayList&lt;&gt;(); //存放所有修改过的对象

    //遍历前端发来的要修改信息的对象集合
    for (SpecificRegular specificRegular : specificRegulars) {

        //通过前端传递的具体规则id在数据库找到对应的具体规则
        SpecificRegular specificRegularMy = specificRegularService.queryOneSpecificRegularByID(specificRegular.getSpecificRegularId());

        if (specificRegularMy != null) {

            //语音播报文字不为空,扣分情况不为0
            if (StringUtils.hasText(specificRegular.getVoiceBroadcastText()) &amp;&amp; specificRegular.getDemeritState() != 0) {
                log.info(&quot;语音播报文字不为空,扣分情况不为0&quot;);

                //判断前端传来的参数与数据库里的参数是否相等
                if (!specificRegular.getVoiceBroadcastText().equals(specificRegularMy.getVoiceBroadcastText()) || !specificRegular.getDemeritState().equals(specificRegularMy.getDemeritState())) {
                    log.info(&quot;前端传来的参数与数据库里的参数不相等!&quot;);

                    //生成语音包
                    String audioText = specificRegular.getVoiceBroadcastText() + &quot;,扣&quot; + specificRegular.getDemeritState() + &quot;分&quot;;
                    //拿到当前项目类型(语音包名称需要)
                    Project project = projectService.queryOneProjectByID(specificRegularMy.getProjectId());
                    //名称(2(科目)-1(倒车入库的编号)-10(所有项目扣分参考编号))
                    String audioFileFirstName = project.getProjectTypeId().toString() + &quot;-&quot; + specifi
</code></pre>

原文地址: https://www.cveoy.top/t/topic/iKEj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录