Browse Source

策略更新

develop
wangsixiang 11 months ago
parent
commit
70f05d7317
  1. 18
      zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java

18
zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java

@ -145,15 +145,15 @@ public class DcWarningServiceImpl implements IDcWarningService
String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息 String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息
JSONObject jsonObjectOne = new JSONObject(otherConfig);//原始数据库数据 JSONObject jsonObjectOne = new JSONObject(otherConfig);//原始数据库数据
JSONObject jsonObjectTwo = new JSONObject(otherConfigString); JSONObject jsonObjectTwo = new JSONObject(otherConfigString);
int videoListLength = jsonObjectOne.getJSONArray("videoList").length();//已经存在数据库的图片的长度 int picturesLength = jsonObjectOne.getJSONArray("pictures").length();//已经存在数据库的图片的长度
if (videoListLength>=10&&jsonObjectTwo.get("videoList")!=null){//如果数据长度大于等于10,对第十位进行替换 if (picturesLength>=10&&jsonObjectTwo.get("pictures")!=null){//如果数据长度大于等于10,对第十位进行替换
JSONArray videoList = jsonObjectOne.getJSONArray("videoList");//获取图片数组 JSONArray pictures = jsonObjectOne.getJSONArray("pictures");//获取图片数组
videoList.put(9,jsonObjectTwo.get("videoList")); //替换第十个元素 pictures.put(9,jsonObjectTwo.getJSONArray("pictures").getString(0)); //替换第十个元素
jsonObjectOne.put("videoList", videoList);//更新 jsonObjectOne 中的 videoList 数组 jsonObjectOne.put("pictures", pictures);//更新 jsonObjectOne中的pictures 数组
if (jsonObjectOne.getJSONArray("pictures").length()>=10&&jsonObjectTwo.get("pictures")!=null){ if (jsonObjectOne.getJSONArray("videoList").length()>=10&&jsonObjectTwo.get("videoList")!=null){
JSONArray pictures = jsonObjectOne.getJSONArray("pictures"); JSONArray videoList = jsonObjectOne.getJSONArray("videoList");
pictures.put(9,jsonObjectTwo.get("pictures")); videoList.put(9,jsonObjectTwo.getJSONArray("videoList").getString(0));
jsonObjectOne.put("pictures",pictures); jsonObjectOne.put("videoList",videoList);
} }
redisCache.setCacheObject(WARNINGDATA+key,dataId,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//重新设置延迟时间 redisCache.setCacheObject(WARNINGDATA+key,dataId,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//重新设置延迟时间
return dcWarningMapper.updateOtherConfig(dataId,jsonObjectOne.toString());//修改数据库配置 return dcWarningMapper.updateOtherConfig(dataId,jsonObjectOne.toString());//修改数据库配置

Loading…
Cancel
Save