|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.xy.annotate.Runners;
|
|
import com.xy.annotate.Runners;
|
|
import com.xy.collections.list.JArrayList;
|
|
import com.xy.collections.list.JArrayList;
|
|
import com.xy.collections.list.JList;
|
|
import com.xy.collections.list.JList;
|
|
|
|
+import com.xy.collections.map.JMap;
|
|
import com.xy.dto.SysCodeConfigureDto;
|
|
import com.xy.dto.SysCodeConfigureDto;
|
|
import com.xy.entity.SysCodeConfigure;
|
|
import com.xy.entity.SysCodeConfigure;
|
|
import com.xy.entity.SysCodeConfigureRedis;
|
|
import com.xy.entity.SysCodeConfigureRedis;
|
|
@@ -84,7 +85,7 @@ public class SysCodeConfigureServiceImpl extends ServiceImpl<SysCodeConfigureMap
|
|
SysCodeConfigure saveInfo = copy(SysCodeConfigure.class, save)
|
|
SysCodeConfigure saveInfo = copy(SysCodeConfigure.class, save)
|
|
.createUserTime(AuthorizeUtils.getLoginId(Long.class));
|
|
.createUserTime(AuthorizeUtils.getLoginId(Long.class));
|
|
save(saveInfo);
|
|
save(saveInfo);
|
|
- refuRedis(saveInfo);
|
|
|
|
|
|
+ refuRedis(saveInfo, 1);
|
|
return R.ok();
|
|
return R.ok();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -94,7 +95,7 @@ public class SysCodeConfigureServiceImpl extends ServiceImpl<SysCodeConfigureMap
|
|
SysCodeConfigure updateInfo = copy(SysCodeConfigure.class, update)
|
|
SysCodeConfigure updateInfo = copy(SysCodeConfigure.class, update)
|
|
.updateUserTime(AuthorizeUtils.getLoginId(Long.class));
|
|
.updateUserTime(AuthorizeUtils.getLoginId(Long.class));
|
|
updateById(updateInfo);
|
|
updateById(updateInfo);
|
|
- refuRedis(updateInfo);
|
|
|
|
|
|
+ refuRedis(updateInfo, 1);
|
|
return R.ok();
|
|
return R.ok();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -105,21 +106,28 @@ public class SysCodeConfigureServiceImpl extends ServiceImpl<SysCodeConfigureMap
|
|
//删除编码
|
|
//删除编码
|
|
List<SysCodeConfigure> list = list(new LambdaQueryWrapper<SysCodeConfigure>().in(SysCodeConfigure::getCode, del.getCode()));
|
|
List<SysCodeConfigure> list = list(new LambdaQueryWrapper<SysCodeConfigure>().in(SysCodeConfigure::getCode, del.getCode()));
|
|
removeBatchByIds(del.getCode());
|
|
removeBatchByIds(del.getCode());
|
|
- //删除子编码
|
|
|
|
- JList<SysCodeConfigure> paters = new JArrayList<>(list).filter().isNull(SysCodeConfigure::getPaterCode).list();
|
|
|
|
- JList<SysCodeConfigure> paters2 = new JArrayList<>(list).filter().eq(SysCodeConfigure::getPaterCode, "").list();
|
|
|
|
- if (Emptys.check(paters2)) {
|
|
|
|
- paters.addAll(paters2);
|
|
|
|
- }
|
|
|
|
- if (Emptys.check(paters)) {
|
|
|
|
- JList<String> codes = paters.getProperty(SysCodeConfigure::getCode);
|
|
|
|
- remove(new LambdaQueryWrapper<SysCodeConfigure>().in(SysCodeConfigure::getPaterCode, codes));
|
|
|
|
- }
|
|
|
|
|
|
+ //递归删除子编码
|
|
|
|
+ delSon(new JArrayList<>(list).getProperty(SysCodeConfigure::getCode));
|
|
//刷新redis
|
|
//刷新redis
|
|
- list.forEach(sysDict -> refuRedis(sysDict));
|
|
|
|
|
|
+ list.forEach(sysCodeConfigure -> refuRedis(sysCodeConfigure, 2));
|
|
return R.ok();
|
|
return R.ok();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 递归删除子编码
|
|
|
|
+ *
|
|
|
|
+ * @param codes
|
|
|
|
+ */
|
|
|
|
+ private void delSon(List<String> codes) {
|
|
|
|
+ List<SysCodeConfigure> list = list(new LambdaQueryWrapper<SysCodeConfigure>().in(SysCodeConfigure::getPaterCode, codes));
|
|
|
|
+ if (!Emptys.check(list)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ delSon(new JArrayList<>(list).getProperty(SysCodeConfigure::getCode));
|
|
|
|
+ removeBatchByIds(list);
|
|
|
|
+ list.forEach(sysCodeConfigure -> refuRedis(sysCodeConfigure, 2));
|
|
|
|
+ }
|
|
|
|
+
|
|
@ApiOperation("编码树")
|
|
@ApiOperation("编码树")
|
|
@PostMapping("tree")
|
|
@PostMapping("tree")
|
|
public R<List<SysCodeConfigureDto.TreeVo>> tree(@RequestBody SysCodeConfigureDto.TreeDto treeDto) {
|
|
public R<List<SysCodeConfigureDto.TreeVo>> tree(@RequestBody SysCodeConfigureDto.TreeDto treeDto) {
|
|
@@ -146,20 +154,12 @@ public class SysCodeConfigureServiceImpl extends ServiceImpl<SysCodeConfigureMap
|
|
*
|
|
*
|
|
* @param sysCodeConfigure
|
|
* @param sysCodeConfigure
|
|
*/
|
|
*/
|
|
- public void refuRedis(SysCodeConfigure sysCodeConfigure) {
|
|
|
|
- List<SysCodeConfigure> list;
|
|
|
|
- String key = sysCodeConfigure.getPaterCode();
|
|
|
|
- if (!Emptys.check(key)) {
|
|
|
|
- //父字典
|
|
|
|
- list = list(new LambdaQueryWrapper<SysCodeConfigure>().eq(SysCodeConfigure::getPaterCode, sysCodeConfigure.getCode()));
|
|
|
|
- key = sysCodeConfigure.getCode();
|
|
|
|
|
|
+ public void refuRedis(SysCodeConfigure sysCodeConfigure, int work) {
|
|
|
|
+ SysCodeConfigureRedis sysCodeConfigureRedis = copy(SysCodeConfigureRedis.class, sysCodeConfigure);
|
|
|
|
+ if (work == 1) {
|
|
|
|
+ redisService.setMap(SysCodeConfigureUtils.SYS_CODE_CONFIGURE_PREFIX, sysCodeConfigureRedis.getCode(), sysCodeConfigureRedis);
|
|
} else {
|
|
} else {
|
|
- //子字典
|
|
|
|
- list = list(new LambdaQueryWrapper<SysCodeConfigure>().eq(SysCodeConfigure::getPaterCode, key));
|
|
|
|
- }
|
|
|
|
- redisService.removeMap(SysCodeConfigureUtils.getKey(key));
|
|
|
|
- for (SysCodeConfigure sysCodeConfigureInfo : list) {
|
|
|
|
- redisService.setMap(SysCodeConfigureUtils.getKey(key), sysCodeConfigureInfo.getCode(), copy(SysCodeConfigureRedis.class, sysCodeConfigureInfo));
|
|
|
|
|
|
+ redisService.removeMap(SysCodeConfigureUtils.SYS_CODE_CONFIGURE_PREFIX, sysCodeConfigureRedis.getCode());
|
|
}
|
|
}
|
|
log.info("系统编码刷新redis完成~");
|
|
log.info("系统编码刷新redis完成~");
|
|
}
|
|
}
|
|
@@ -170,19 +170,13 @@ public class SysCodeConfigureServiceImpl extends ServiceImpl<SysCodeConfigureMap
|
|
@Runners
|
|
@Runners
|
|
public void loadRedis() {
|
|
public void loadRedis() {
|
|
List<SysCodeConfigure> sysCodeConfigures = list();
|
|
List<SysCodeConfigure> sysCodeConfigures = list();
|
|
- List<SysCodeConfigureRedis> sysCodeConfigureRedis = Beans.copy(SysCodeConfigureRedis.class, sysCodeConfigures);
|
|
|
|
- JList<SysCodeConfigureRedis> list = new JArrayList<>(sysCodeConfigureRedis);
|
|
|
|
- JList<SysCodeConfigureRedis> paters = list.filter().isNull(SysCodeConfigureRedis::getPaterCode).list();
|
|
|
|
- JList<SysCodeConfigureRedis> paters2 = list.filter().eq(SysCodeConfigureRedis::getPaterCode, "").list();
|
|
|
|
- if (Emptys.check(paters2)) {
|
|
|
|
- paters.addAll(paters2);
|
|
|
|
|
|
+ if (!Emptys.check(sysCodeConfigures)) {
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
- redisService.removeLikeMap(SysCodeConfigureUtils.SYS_CODE_CONFIGURE_PREFIX);
|
|
|
|
- //[父code -> 子列表]数据结构写入redis
|
|
|
|
- paters.forEach(sysDict -> {
|
|
|
|
- JList<SysCodeConfigureRedis> sysCodeConfigureRedisJList = list.filter().eq(SysCodeConfigureRedis::getPaterCode, sysDict.getCode()).list();
|
|
|
|
- sysCodeConfigureRedisJList.forEach(sysCodeConfigureRediss -> redisService.setMap(SysCodeConfigureUtils.getKey(sysDict.getCode()), sysCodeConfigureRediss.getCode(), sysCodeConfigureRediss));
|
|
|
|
- });
|
|
|
|
|
|
+ List<SysCodeConfigureRedis> sysCodeConfigureRedis = Beans.copy(SysCodeConfigureRedis.class, sysCodeConfigures);
|
|
|
|
+ JMap<String, SysCodeConfigureRedis> sysCodeConfiguresJMaps = new JArrayList<>(sysCodeConfigureRedis).toMap(SysCodeConfigureRedis::getCode).cover();
|
|
|
|
+ redisService.remove(SysCodeConfigureUtils.SYS_CODE_CONFIGURE_PREFIX);
|
|
|
|
+ redisService.setMap(SysCodeConfigureUtils.SYS_CODE_CONFIGURE_PREFIX, sysCodeConfiguresJMaps);
|
|
log.info("系统编码写入redis完成~");
|
|
log.info("系统编码写入redis完成~");
|
|
}
|
|
}
|
|
}
|
|
}
|