Commit fda64552 authored by tangwei's avatar tangwei

Merge branch 'develop_ccs' of http://172.16.10.76/moa/amos-boot-biz into develop_ccs

parents df154c53 a2bbd1eb
...@@ -15,6 +15,7 @@ import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; ...@@ -15,6 +15,7 @@ import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel; import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.privilege.model.DepartmentModel; import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel; import com.yeejoin.amos.feign.privilege.model.RoleModel;
import org.apache.commons.lang3.ObjectUtils;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
...@@ -68,7 +69,12 @@ public class ControllerAop { ...@@ -68,7 +69,12 @@ public class ControllerAop {
public void doBefore(JoinPoint joinPoint) { public void doBefore(JoinPoint joinPoint) {
PermissionInterceptorContext.clean(); PermissionInterceptorContext.clean();
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest(); HttpServletRequest request = null;
if(ObjectUtils.isNotEmpty(attributes)){
request = attributes.getRequest();
} else {
return;
}
// 不需要添加请求头的接口 // 不需要添加请求头的接口
String[] url = new String[]{"/api/user/save/curCompany", "/jcs/command/lookHtmlText", String[] url = new String[]{"/api/user/save/curCompany", "/jcs/command/lookHtmlText",
"/jcs/common/duty-person/findByDutyAreaId", "/tzs/wechatBack", "/tzs/elevator/getElevatorInfo"}; "/jcs/common/duty-person/findByDutyAreaId", "/tzs/wechatBack", "/tzs/elevator/getElevatorInfo"};
......
...@@ -11,6 +11,7 @@ import java.util.stream.Collectors; ...@@ -11,6 +11,7 @@ import java.util.stream.Collectors;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.yeejoin.equipmanage.common.utils.*;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -62,12 +63,6 @@ import com.yeejoin.equipmanage.common.enums.IndustryEnum; ...@@ -62,12 +63,6 @@ import com.yeejoin.equipmanage.common.enums.IndustryEnum;
import com.yeejoin.equipmanage.common.enums.OnBoardEquipmentEnum; import com.yeejoin.equipmanage.common.enums.OnBoardEquipmentEnum;
import com.yeejoin.equipmanage.common.enums.SystemDicTypeEum; import com.yeejoin.equipmanage.common.enums.SystemDicTypeEum;
import com.yeejoin.equipmanage.common.enums.TrueOrFalseEnum; import com.yeejoin.equipmanage.common.enums.TrueOrFalseEnum;
import com.yeejoin.equipmanage.common.utils.CommonResponseUtil;
import com.yeejoin.equipmanage.common.utils.DateUtils;
import com.yeejoin.equipmanage.common.utils.NameUtils;
import com.yeejoin.equipmanage.common.utils.ParsePropertyUtil;
import com.yeejoin.equipmanage.common.utils.QRCodeUtil;
import com.yeejoin.equipmanage.common.utils.StringUtil;
import com.yeejoin.equipmanage.common.vo.CarForUE4VO; import com.yeejoin.equipmanage.common.vo.CarForUE4VO;
import com.yeejoin.equipmanage.common.vo.CarInfosResponse; import com.yeejoin.equipmanage.common.vo.CarInfosResponse;
import com.yeejoin.equipmanage.common.vo.EquipStateOnCarVo; import com.yeejoin.equipmanage.common.vo.EquipStateOnCarVo;
...@@ -244,18 +239,17 @@ public class CarController extends AbstractBaseController { ...@@ -244,18 +239,17 @@ public class CarController extends AbstractBaseController {
}); });
} }
Car car2= iCarService.saveOne(car); Car car2= iCarService.saveOne(car);
refreshCount(car.getBizOrgCode()); CarController controllerProxy = SpringUtils.getBean(CarController.class);
controllerProxy.refreshCount(car.getBizOrgCode());
return car2; return car2;
} }
@Async @Async
public void refreshCount(String bizOrgCode) { public void refreshCount(String bizOrgCode) {
// 刷新分类数量缓存
iCarService.refreshStaData(); iCarService.refreshStaData();
try { // 刷新分类树缓存
fireFightingSystemServiceImpl.refreshCarTypeAndCount(bizOrgCode); fireFightingSystemServiceImpl.refreshCarTypeAndCount(bizOrgCode);
} catch (Exception e) {
}
} }
@Async @Async
public void refreshCount(List<Car> list) { public void refreshCount(List<Car> list) {
...@@ -327,6 +321,8 @@ public class CarController extends AbstractBaseController { ...@@ -327,6 +321,8 @@ public class CarController extends AbstractBaseController {
// saveFile(carInstance);视频图片文件后期统一处理 // saveFile(carInstance);视频图片文件后期统一处理
EquipmentSpecificSerivceImpl.registerMqttTopic(car.getIotCode(), equipmentIotMqttReceiveConfig); EquipmentSpecificSerivceImpl.registerMqttTopic(car.getIotCode(), equipmentIotMqttReceiveConfig);
Car car1= iCarService.updateOneById(car); Car car1= iCarService.updateOneById(car);
CarController controllerProxy = SpringUtils.getBean(CarController.class);
controllerProxy.refreshCount(car.getBizOrgCode());
refreshCount(car.getBizOrgCode()); refreshCount(car.getBizOrgCode());
return car1; return car1;
} }
...@@ -1105,7 +1101,8 @@ public class CarController extends AbstractBaseController { ...@@ -1105,7 +1101,8 @@ public class CarController extends AbstractBaseController {
}); });
boolean flag = iCarService.removeOneByIds(idList); boolean flag = iCarService.removeOneByIds(idList);
if(flag) { if(flag) {
refreshCount(cars) ; CarController controllerProxy = SpringUtils.getBean(CarController.class);
controllerProxy.refreshCount(cars);
} }
return flag; return flag;
} }
......
...@@ -10,6 +10,7 @@ import com.yeejoin.equipmanage.common.entity.vo.EquipmentDetailDownloadVO; ...@@ -10,6 +10,7 @@ import com.yeejoin.equipmanage.common.entity.vo.EquipmentDetailDownloadVO;
import com.yeejoin.equipmanage.common.enums.ExcelEnums; import com.yeejoin.equipmanage.common.enums.ExcelEnums;
import com.yeejoin.equipmanage.common.utils.ExcelUtils; import com.yeejoin.equipmanage.common.utils.ExcelUtils;
import com.yeejoin.equipmanage.common.utils.NameUtils; import com.yeejoin.equipmanage.common.utils.NameUtils;
import com.yeejoin.equipmanage.common.utils.SpringUtils;
import com.yeejoin.equipmanage.common.utils.StringUtil; import com.yeejoin.equipmanage.common.utils.StringUtil;
import com.yeejoin.equipmanage.common.vo.EquipmentDate; import com.yeejoin.equipmanage.common.vo.EquipmentDate;
import com.yeejoin.equipmanage.dto.ExcelDto; import com.yeejoin.equipmanage.dto.ExcelDto;
...@@ -155,7 +156,8 @@ public class EquipmentDetailController extends AbstractBaseController { ...@@ -155,7 +156,8 @@ public class EquipmentDetailController extends AbstractBaseController {
if (syncSwitch) { if (syncSwitch) {
equipmentSpecificSerivce.equipSpecificDataSync(equipmentId); equipmentSpecificSerivce.equipSpecificDataSync(equipmentId);
} }
refreshCount(vo.getBizOrgCode()); EquipmentDetailController controllerProxy = SpringUtils.getBean(EquipmentDetailController.class);
controllerProxy.refreshCount(vo.getBizOrgCode());
return date; return date;
} }
...@@ -263,7 +265,8 @@ public class EquipmentDetailController extends AbstractBaseController { ...@@ -263,7 +265,8 @@ public class EquipmentDetailController extends AbstractBaseController {
if (syncSwitch) { if (syncSwitch) {
equipmentSpecificSerivce.equipSpecificDataSync(bean.getEquipmentId()); equipmentSpecificSerivce.equipSpecificDataSync(bean.getEquipmentId());
} }
refreshCount(vo.getBizOrgCode()); EquipmentDetailController controllerProxy = SpringUtils.getBean(EquipmentDetailController.class);
controllerProxy.refreshCount(vo.getBizOrgCode());
return equipmentDate; return equipmentDate;
} }
......
package com.yeejoin.equipmanage.service.impl; package com.yeejoin.equipmanage.service.impl;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.equipmanage.common.enums.ConfigPageTopicEnum; import com.yeejoin.equipmanage.common.enums.ConfigPageTopicEnum;
import com.yeejoin.equipmanage.listener.IntegratePageDataListener; import com.yeejoin.equipmanage.listener.IntegratePageDataListener;
import com.yeejoin.equipmanage.service.IMaintenanceResourceDataService; import com.yeejoin.equipmanage.service.IMaintenanceResourceDataService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner; import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -29,9 +31,24 @@ public class ApplicationRunnerImpl implements ApplicationRunner { ...@@ -29,9 +31,24 @@ public class ApplicationRunnerImpl implements ApplicationRunner {
@Autowired @Autowired
IntegratePageDataListener integratePageDataListener; IntegratePageDataListener integratePageDataListener;
@Autowired
RedisUtils redisUtils;
@Value("${redis_car_type_count}")
private String carTypeAndCount;
@Value("${redis_equip_type_count}")
private String equipTypeAndCount;
@Override @Override
public void run(ApplicationArguments args) throws Exception { public void run(ApplicationArguments args) throws Exception {
// 清空装备分类树缓存
redisUtils.getAndDeletePatternKeys(carTypeAndCount + "*");
// 清空车辆分类树缓存
redisUtils.getAndDeletePatternKeys(equipTypeAndCount + "*");
// 清空单位分类数量统计缓存
redisUtils.getAndDeletePatternKeys(SourcesStatisticsImpl.PREFIX_CATEGORY_COUNT + "*");
maintenanceResourceDataService.subscribeTopic(); maintenanceResourceDataService.subscribeTopic();
emqKeeper.getMqttClient().subscribe(ConfigPageTopicEnum.INTEGRATE.getTopic(),2, integratePageDataListener); emqKeeper.getMqttClient().subscribe(ConfigPageTopicEnum.INTEGRATE.getTopic(), 2, integratePageDataListener);
} }
} }
...@@ -1620,10 +1620,10 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS ...@@ -1620,10 +1620,10 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
@Override @Override
public void refreshStaData() { public void refreshStaData() {
List<Map<String, Object>> result = this.baseMapper.queryCompanyCarStaData(); List<Map<String, Object>> result = this.baseMapper.queryCompanyCarStaData();
result.forEach(m -> redisUtils.set((buildKey(m)), m.get("total"),86400)); result.forEach(m -> redisUtils.set((buildKey(m)), m.get("total"), 86400));
} }
private String buildKey(Map<String, Object> row) { private String buildKey(Map<String, Object> row) {
return row.get("bizOrgCode").toString() + "_" + SourceTypeEnum.CAR.getCode() + "_" + row.get("categoryCode").toString(); return SourcesStatisticsImpl.PREFIX_CATEGORY_COUNT + row.get("bizOrgCode").toString() + "_" + SourceTypeEnum.CAR.getCode() + "_" + row.get("categoryCode").toString();
} }
} }
...@@ -1595,7 +1595,7 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM ...@@ -1595,7 +1595,7 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
} }
private String buildKey(Map<String, Object> row) { private String buildKey(Map<String, Object> row) {
return row.get("bizOrgCode").toString() + "_" + SourceTypeEnum.EQUIPMENT.getCode() + "_" + row.get("categoryCode").toString(); return SourcesStatisticsImpl.PREFIX_CATEGORY_COUNT + row.get("bizOrgCode").toString() + "_" + SourceTypeEnum.EQUIPMENT.getCode() + "_" + row.get("categoryCode").toString();
} }
} }
...@@ -1010,16 +1010,17 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste ...@@ -1010,16 +1010,17 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
return Collections.singletonList(parentNode); return Collections.singletonList(parentNode);
} }
public Object getEquipmentTypeAndCount(String bizOrgCode) throws Exception { @Override
public Object getEquipmentTypeAndCount(String bizOrgCode) {
if (redisUtils.hasKey(equipTypeAndCount + bizOrgCode)) { if (redisUtils.hasKey(equipTypeAndCount + bizOrgCode)) {
List<EquipmentCategory> typeList = JSONArray.parseArray( return JSONArray.parseArray(
JSONArray.toJSONString(redisUtils.get(equipTypeAndCount + bizOrgCode)), EquipmentCategory.class); JSONArray.toJSONString(redisUtils.get(equipTypeAndCount + bizOrgCode)), EquipmentCategory.class);
return typeList;
} else { } else {
return refreshEquipmentTypeAndCount(bizOrgCode); return refreshEquipmentTypeAndCount(bizOrgCode);
} }
} }
public Object refreshEquipmentTypeAndCount(String bizOrgCode) throws Exception { @Override
public Object refreshEquipmentTypeAndCount(String bizOrgCode) {
List<EquipmentCategory> responseList = this.typeList(); List<EquipmentCategory> responseList = this.typeList();
if (responseList == null || responseList.size() < 1) { if (responseList == null || responseList.size() < 1) {
return null; return null;
...@@ -1028,21 +1029,22 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste ...@@ -1028,21 +1029,22 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
.filter(i -> !i.getCode().startsWith("2") && "2".equals(i.getIndustryCode())) .filter(i -> !i.getCode().startsWith("2") && "2".equals(i.getIndustryCode()))
.collect(Collectors.toList()); .collect(Collectors.toList());
List<EquipmentCategory> list = typeListTree(equipmentTypeList, bizOrgCode, SourceTypeEnum.EQUIPMENT); List<EquipmentCategory> list = typeListTree(equipmentTypeList, bizOrgCode, SourceTypeEnum.EQUIPMENT);
redisUtils.set(equipTypeAndCount + bizOrgCode, list); redisUtils.set(equipTypeAndCount + bizOrgCode, list, 86400);
return list; return list;
} }
public Object getCarTypeAndCount(String bizOrgCode) throws Exception { @Override
public Object getCarTypeAndCount(String bizOrgCode) {
if (redisUtils.hasKey(carTypeAndCount + bizOrgCode)) { if (redisUtils.hasKey(carTypeAndCount + bizOrgCode)) {
List<EquipmentCategory> typeList = JSONArray.parseArray( List<EquipmentCategory> typeList = JSONArray.parseArray(
JSONArray.toJSONString(redisUtils.get(carTypeAndCount + bizOrgCode)), EquipmentCategory.class); JSONArray.toJSONString(redisUtils.get(carTypeAndCount + bizOrgCode)), EquipmentCategory.class);
return typeList; return typeList;
} else { } else {
return refreshCarTypeAndCount(bizOrgCode); return refreshCarTypeAndCount(bizOrgCode);
} }
} }
public Object refreshCarTypeAndCount(String bizOrgCode) throws Exception { @Override
public Object refreshCarTypeAndCount(String bizOrgCode) {
List<EquipmentCategory> responseList = this.typeList(); List<EquipmentCategory> responseList = this.typeList();
if (responseList == null || responseList.size() < 1) { if (responseList == null || responseList.size() < 1) {
return null; return null;
......
...@@ -2,8 +2,6 @@ package com.yeejoin.equipmanage.service.impl; ...@@ -2,8 +2,6 @@ package com.yeejoin.equipmanage.service.impl;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.equipmanage.common.enums.SourceTypeEnum; import com.yeejoin.equipmanage.common.enums.SourceTypeEnum;
import com.yeejoin.equipmanage.service.ICarService;
import com.yeejoin.equipmanage.service.IEquipmentDetailService;
import com.yeejoin.equipmanage.service.ISourceStatistics; import com.yeejoin.equipmanage.service.ISourceStatistics;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -21,12 +19,14 @@ public class SourcesStatisticsImpl implements ISourceStatistics { ...@@ -21,12 +19,14 @@ public class SourcesStatisticsImpl implements ISourceStatistics {
@Autowired @Autowired
private RedisUtils redisUtil; private RedisUtils redisUtil;
public static String PREFIX_CATEGORY_COUNT = "CATEGORY_COUNT_";
@Override @Override
public int equipCategoryStatistics(String bizOrgCode, SourceTypeEnum sourceType, String categoryCode) { public int equipCategoryStatistics(String bizOrgCode, SourceTypeEnum sourceType, String categoryCode) {
// 计算处通用code,用来上下级匹配如12001010000->1200101 // 计算处通用code,用来上下级匹配如12001010000->1200101
String treeCode = subStringZero(categoryCode); String treeCode = subStringZero(categoryCode);
Set<String> keys = redisUtil.getKeys(buildKey(bizOrgCode, sourceType.getCode(), treeCode)); Set<String> keys = redisUtil.getKeys(buildPattenKey(bizOrgCode, sourceType.getCode(), treeCode));
if (keys.size() > 0) { if (keys.size() > 0) {
//求和 //求和
return this.sumNumber(keys); return this.sumNumber(keys);
...@@ -43,10 +43,18 @@ public class SourcesStatisticsImpl implements ISourceStatistics { ...@@ -43,10 +43,18 @@ public class SourcesStatisticsImpl implements ISourceStatistics {
} }
} }
} }
return this.sumNumber(keys); return this.sumNumberAndInitRedis(bizOrgCode,sourceType,treeCode, keys);
} }
} }
private int sumNumberAndInitRedis(String bizOrgCode, SourceTypeEnum sourceType, String treeCode, Set<String> keys) {
int result = this.sumNumber(keys);
if(result == 0){
redisUtil.set(buildKey(bizOrgCode,sourceType.getCode(),treeCode),0,86400);
}
return result;
}
private int sumNumber(Set<String> keys) { private int sumNumber(Set<String> keys) {
return keys.stream().filter(k -> redisUtil.get(k) != null).mapToInt(k -> Integer.parseInt(redisUtil.get(k).toString())).sum(); return keys.stream().filter(k -> redisUtil.get(k) != null).mapToInt(k -> Integer.parseInt(redisUtil.get(k).toString())).sum();
} }
...@@ -57,7 +65,11 @@ public class SourcesStatisticsImpl implements ISourceStatistics { ...@@ -57,7 +65,11 @@ public class SourcesStatisticsImpl implements ISourceStatistics {
return new StringBuffer(String.valueOf(noZero)).reverse().toString(); return new StringBuffer(String.valueOf(noZero)).reverse().toString();
} }
private String buildPattenKey(String bizOrgCode, String sourceType, String treeCode) {
return PREFIX_CATEGORY_COUNT + bizOrgCode + "*_" + sourceType + "_" + treeCode + "*";
}
private String buildKey(String bizOrgCode, String sourceType, String treeCode) { private String buildKey(String bizOrgCode, String sourceType, String treeCode) {
return bizOrgCode + "*_" + sourceType + "_" + treeCode + "*"; return PREFIX_CATEGORY_COUNT + bizOrgCode + "_" + sourceType + "_" + treeCode;
} }
} }
...@@ -11,6 +11,7 @@ import java.util.stream.Collectors; ...@@ -11,6 +11,7 @@ import java.util.stream.Collectors;
import javax.annotation.Resource; import javax.annotation.Resource;
import com.yeejoin.equipmanage.common.utils.SpringUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
...@@ -395,7 +396,9 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements ...@@ -395,7 +396,9 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
} }
equipmentSpecificMapper.insert(equipmentSpecific); equipmentSpecificMapper.insert(equipmentSpecific);
refreshCount(equipmentSpecific.getBizOrgCode());//添加对于装备类型统计数据的刷新 StockServiceImpl controllerProxy = SpringUtils.getBean(StockServiceImpl.class);
//添加对于装备类型统计数据的刷新
controllerProxy.refreshCount(equipmentSpecific.getBizOrgCode());
//位置编码不为空入库 //位置编码不为空入库
if (equipmentDetailDownloadVOS.get(i) != null && equipmentDetailDownloadVOS.get(i).getWarehouseStructCode() != null) { if (equipmentDetailDownloadVOS.get(i) != null && equipmentDetailDownloadVOS.get(i).getWarehouseStructCode() != null) {
QueryWrapper<WarehouseStructure> warehouseStructureQueryWrapper = new QueryWrapper<>(); QueryWrapper<WarehouseStructure> warehouseStructureQueryWrapper = new QueryWrapper<>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment