package com.ld.igds.init;
|
|
import com.bstek.bdf2.core.model.DefaultCompany;
|
import com.bstek.dorado.annotation.Expose;
|
import com.ld.igds.common.CoreCommonService;
|
import com.ld.igds.common.CoreSerService;
|
import com.ld.igds.sys.service.DicTriggerService;
|
import com.ld.igds.sys.service.SysCompanyService;
|
import com.ld.igds.sys.service.SysDeptService;
|
import com.ld.igds.sys.service.SystemService;
|
import com.ld.igds.view.service.BuildingService;
|
import com.ld.igds.view.service.HDepotService;
|
import com.ld.igds.view.service.DeviceService;
|
import com.ld.igds.view.service.SysConfService;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.boot.CommandLineRunner;
|
import org.springframework.core.annotation.Order;
|
import org.springframework.stereotype.Service;
|
|
import java.util.List;
|
|
/**
|
* 配置系统级别的项目启动初始化信息
|
*
|
* @author Andy
|
*/
|
@Service
|
@Slf4j
|
@Order(value = 1)
|
public class SystemRunner implements CommandLineRunner {
|
|
@Autowired
|
private DicTriggerService dicService;
|
@Autowired
|
private CoreSerService coreSerService;
|
@Autowired
|
private HDepotService depotService;
|
@Autowired
|
private BuildingService buildingService;
|
@Autowired
|
private DeviceService deviceService;
|
@Autowired
|
private SysConfService sysConfService;
|
@Autowired
|
private SysDeptService sysDeptService;
|
@Autowired
|
private SysCompanyService companyService;
|
@Autowired
|
private SystemService systemService;
|
@Autowired
|
private CoreCommonService coreCommonService;
|
|
@Override
|
public void run(String... args) throws Exception {
|
|
List<DefaultCompany> list = companyService.getAll();
|
//放入缓存
|
coreCommonService.setCacheCompany(list);
|
|
for (DefaultCompany company : list) {
|
flushCache(company.getId(), company.getName());
|
}
|
|
//初始化用户部门内存
|
sysDeptService.initUserDeptMap();
|
|
// 刷新菜单
|
systemService.refreshUrlCache();
|
}
|
|
public void flushCache(String companyId, String name) throws Exception {
|
|
// 设置分机全部掉线
|
coreSerService.allOffLine(companyId);
|
|
// 初始化缓存
|
dicService.refreshCache(companyId);
|
|
//分机
|
coreSerService.refreshCache(companyId);
|
|
//初始化仓库
|
depotService.flushCache(companyId);
|
|
//系统配置
|
sysConfService.flushCacheSysConf(companyId);
|
|
// 需要先刷新仓库缓存后刷新配置
|
Thread.sleep(500);
|
|
//参数配置
|
depotService.flushConfCache(companyId);
|
|
//建筑物
|
buildingService.refreshCache(companyId);
|
|
//设备配置
|
deviceService.refreshCache(companyId);
|
|
//子部门配置
|
sysDeptService.flushDeptCache(companyId);
|
|
//初始化控制柜仓库的虚拟用户
|
depotService.initUserDeptMap(companyId);
|
|
log.info("* ");
|
log.info("* ========================");
|
log.info("* ");
|
log.info("* 组织={},初始化缓存完成…………", companyId);
|
log.info("* ");
|
log.info("* ========================");
|
log.info("* ");
|
}
|
|
|
/**
|
* 刷新所有缓存,包括菜单
|
*
|
* @param companyId
|
* @throws Exception
|
*/
|
@Expose
|
public void flushAllCache(String companyId) throws Exception {
|
|
flushCache(companyId, "手动调用");
|
//公司信息放入缓存
|
List<DefaultCompany> list = companyService.getAll();
|
coreCommonService.setCacheCompany(list);
|
|
// 刷新菜单
|
systemService.refreshUrlCache();
|
}
|
}
|