Commit d67ba612 authored by suhuiguang's avatar suhuiguang

1.增加数量统计

parent eae491cb
...@@ -456,6 +456,10 @@ public class RedisUtils { ...@@ -456,6 +456,10 @@ public class RedisUtils {
} }
return null; return null;
} }
public Set<String> getPatternKeys(String pattern) {
return redisTemplate.keys(pattern);
}
/** /**
* 获取指定前缀key列表 * 获取指定前缀key列表
* *
......
package com.yeejoin.equipmanage.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
/**
* @author DELL
*/
@AllArgsConstructor
@Getter
public enum SourceTypeEnum {
/**
* 资源类型枚举
*/
EQUIPMENT("装备","equipment", "equipmentSpecificSerivceImpl","refreshStaData"),
CAR("车辆","car", "carServiceImpl","refreshStaData");
private String name;
private String code;
private String beanName;
private String methodName;
}
...@@ -2,11 +2,9 @@ package com.yeejoin.equipmanage.controller; ...@@ -2,11 +2,9 @@ package com.yeejoin.equipmanage.controller;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.dto.OrgMenuDto; import com.yeejoin.amos.boot.biz.common.dto.OrgMenuDto;
import com.yeejoin.equipmanage.common.dto.AreaDto; import com.yeejoin.equipmanage.common.dto.AreaDto;
import com.yeejoin.equipmanage.common.entity.Area; import com.yeejoin.equipmanage.common.entity.Area;
import com.yeejoin.equipmanage.common.utils.StringUtil;
import com.yeejoin.equipmanage.common.vo.AreaResquest; import com.yeejoin.equipmanage.common.vo.AreaResquest;
import com.yeejoin.equipmanage.common.vo.UnitAreaTreeVo; import com.yeejoin.equipmanage.common.vo.UnitAreaTreeVo;
import com.yeejoin.equipmanage.service.IAreaService; import com.yeejoin.equipmanage.service.IAreaService;
...@@ -32,8 +30,8 @@ import java.util.Map; ...@@ -32,8 +30,8 @@ import java.util.Map;
@RequestMapping(value = "/area", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "/area", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class AreaController extends AbstractBaseController { public class AreaController extends AbstractBaseController {
@Autowired @Autowired
IAreaService iAreaService; IAreaService iAreaService;
// /** // /**
// * 获取区域树 // * 获取区域树
...@@ -45,103 +43,105 @@ public class AreaController extends AbstractBaseController { ...@@ -45,103 +43,105 @@ public class AreaController extends AbstractBaseController {
// return iAreaService.getAreaTreeVo(); // return iAreaService.getAreaTreeVo();
// } // }
/** /**
* 获取公司部门区域树 * 获取公司部门区域树
* @return list *
*/ * @return list
@TycloudOperation(ApiLevel = UserType.AGENCY) */
@ApiOperation(httpMethod = "GET", value = "根据登陆人获取单位区域树", notes = "根据登陆人获取单位区域树") @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/tree") @ApiOperation(httpMethod = "GET", value = "根据登陆人获取单位区域树", notes = "根据登陆人获取单位区域树")
public List<UnitAreaTreeVo> getSystemTree(){ @GetMapping(value = "/tree")
return iAreaService.getAreaTreeListVo(); public List<UnitAreaTreeVo> getSystemTree() {
} return iAreaService.getAreaTreeListVo();
}
/**
* 获取公司部门树 /**
* @return list * 获取公司部门树
*/ *
@TycloudOperation(ApiLevel = UserType.AGENCY) * @return list
@ApiOperation(httpMethod = "GET", value = "根据登陆人获取公司树", notes = "根据登陆人获取公司树") */
@GetMapping(value = "/companyTreeByUserAndType") @TycloudOperation(ApiLevel = UserType.AGENCY)
public List<OrgMenuDto> companyTreeByUserAndType(){ @ApiOperation(httpMethod = "GET", value = "根据登陆人获取公司树", notes = "根据登陆人获取公司树")
return iAreaService.companyDeptTree(); @GetMapping(value = "/companyTreeByUserAndType")
} public List<OrgMenuDto> companyTreeByUserAndType() {
return iAreaService.companyDeptTree();
/** }
* 根据节点id获取树
*/ /**
@TycloudOperation(ApiLevel = UserType.AGENCY) * 根据节点id获取树
@ApiOperation("区域树") */
@GetMapping(value = "/treeById") @TycloudOperation(ApiLevel = UserType.AGENCY)
public List<UnitAreaTreeVo> getAreaTreeById(@RequestParam Long id, @RequestParam String bizOrgCode) { @ApiOperation("区域树")
if (id == null) { @GetMapping(value = "/treeById")
id = -1L; public List<UnitAreaTreeVo> getAreaTreeById(@RequestParam Long id, @RequestParam String bizOrgCode) {
} if (id == null) {
return iAreaService.getAreaTreeVoById(id, bizOrgCode); id = -1L;
} }
return iAreaService.getAreaTreeVoById(id, bizOrgCode);
/** }
* 获取指定层级区域树,起步2级树
*/ /**
@TycloudOperation(ApiLevel = UserType.AGENCY) * 获取指定层级区域树,起步2级树
@ApiOperation("获取指定层级区域树") */
@GetMapping(value = "/getAreaTierTree") @TycloudOperation(ApiLevel = UserType.AGENCY)
public List<AreaDto> getAreaTierTree(@RequestParam Integer tier) { @ApiOperation("获取指定层级区域树")
return iAreaService.getAreaTierTree(tier); @GetMapping(value = "/getAreaTierTree")
} public List<AreaDto> getAreaTierTree(@RequestParam Integer tier) {
return iAreaService.getAreaTierTree(tier);
/** }
* 根据父节点查询
*/ /**
@RequestMapping(value = "/lists", method = RequestMethod.GET) * 根据父节点查询
@TycloudOperation(ApiLevel = UserType.AGENCY) */
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询") @RequestMapping(value = "/lists", method = RequestMethod.GET)
public IPage<AreaResquest> listPage(Page page, Area area) { @TycloudOperation(ApiLevel = UserType.AGENCY)
return iAreaService.areaList(page, area); @ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
} public IPage<AreaResquest> listPage(Page page, Area area) {
return iAreaService.areaList(page, area);
}
/**
* 保存数据
*/ /**
@RequestMapping(value = "/saveArea", method = RequestMethod.POST) * 保存数据
@TycloudOperation(ApiLevel = UserType.AGENCY) */
@ApiOperation(httpMethod = "POST", value = "新增区域", notes = "新增新增区域") @RequestMapping(value = "/saveArea", method = RequestMethod.POST)
public Object saveArea(@RequestBody AreaResquest areaResquest) { @TycloudOperation(ApiLevel = UserType.AGENCY)
return iAreaService.saveArea(areaResquest); @ApiOperation(httpMethod = "POST", value = "新增区域", notes = "新增新增区域")
} public Object saveArea(@RequestBody AreaResquest areaResquest) {
return iAreaService.saveArea(areaResquest);
/** }
* 保存数据
*/ /**
@RequestMapping(value = "/updateArea", method = RequestMethod.POST) * 保存数据
@TycloudOperation(ApiLevel = UserType.AGENCY) */
@ApiOperation(httpMethod = "POST", value = "修改区域", notes = "修改新增区域") @RequestMapping(value = "/updateArea", method = RequestMethod.POST)
public Object updateArea(@RequestBody AreaResquest areaResquest) { @TycloudOperation(ApiLevel = UserType.AGENCY)
return iAreaService.updateArea(areaResquest); @ApiOperation(httpMethod = "POST", value = "修改区域", notes = "修改新增区域")
} public Object updateArea(@RequestBody AreaResquest areaResquest) {
return iAreaService.updateArea(areaResquest);
/** }
* 删除数据
*/ /**
@TycloudOperation(ApiLevel = UserType.AGENCY) * 删除数据
@ApiOperation(value = "删除") */
@DeleteMapping(value = "/{instanceId}") @TycloudOperation(ApiLevel = UserType.AGENCY)
public int delete(@PathVariable Long instanceId) { @ApiOperation(value = "删除")
return iAreaService.deleteArea(instanceId); @DeleteMapping(value = "/{instanceId}")
} public int delete(@PathVariable Long instanceId) {
return iAreaService.deleteArea(instanceId);
/** }
* 根据id查询
* /**
* @param instanceId * 根据id查询
* @return *
*/ * @param instanceId
@RequestMapping(value = "/getOne", method = RequestMethod.GET) * @return
@TycloudOperation(ApiLevel = UserType.AGENCY) */
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询") @RequestMapping(value = "/getOne", method = RequestMethod.GET)
public Map<String, Object> selectById(@RequestParam Long instanceId) { @TycloudOperation(ApiLevel = UserType.AGENCY)
return iAreaService.getById(instanceId); @ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
} public Map<String, Object> selectById(@RequestParam Long instanceId) {
return iAreaService.getById(instanceId);
}
} }
...@@ -71,4 +71,6 @@ public interface CarMapper extends BaseMapper<Car> { ...@@ -71,4 +71,6 @@ public interface CarMapper extends BaseMapper<Car> {
int equipmentCarListcount(Long teamId, String name,String code,Long id,Boolean isNo); int equipmentCarListcount(Long teamId, String name,String code,Long id,Boolean isNo);
List<CarFusionDto> selectCarAndCarProperty(); List<CarFusionDto> selectCarAndCarProperty();
List<Map<String, Object>> queryCompanyCarStaData();
} }
...@@ -200,4 +200,10 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> { ...@@ -200,4 +200,10 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
* @return 指标详情 * @return 指标详情
*/ */
List<Map<String, String>> getBoxTropicsIndexDetails(); List<Map<String, String>> getBoxTropicsIndexDetails();
/**
* 统计数据
* @return
*/
List<Map<String, Object>> queryCompanyStaData();
} }
...@@ -173,4 +173,9 @@ public interface ICarService extends IService<Car> { ...@@ -173,4 +173,9 @@ public interface ICarService extends IService<Car> {
* @return * @return
*/ */
List<CarFusionDto> getCarFusionList(); List<CarFusionDto> getCarFusionList();
/**
* 更新redis 统计数据
*/
void refreshStaData();
} }
...@@ -194,4 +194,9 @@ public interface IEquipmentSpecificSerivce extends IService<EquipmentSpecific> { ...@@ -194,4 +194,9 @@ public interface IEquipmentSpecificSerivce extends IService<EquipmentSpecific> {
* @return * @return
*/ */
Map<String, List<Map<String, String>>> getFessIndexDetails(); Map<String, List<Map<String, String>>> getFessIndexDetails();
/**
* 更新redis 统计数据
*/
void refreshStaData();
} }
package com.yeejoin.equipmanage.service;
import com.yeejoin.equipmanage.common.enums.SourceTypeEnum;
public interface ISourceStatistics {
/**
* 装备、车辆按照单位及分类统计
*
* @param bizOrgCode 单位部门code
* @param sourceType 资源类型
* @param categoryCode 资源分类code
* @return int 数量
*/
int equipCategoryStatistics(String bizOrgCode, SourceTypeEnum sourceType, String categoryCode);
}
package com.yeejoin.equipmanage.service.impl;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.context.SpringContextHelper;
import java.lang.reflect.Method;
import java.util.Set;
/**
* @author DELL
*/
@Service
public class SourcesStatisticsImpl implements ISourceStatistics {
@Autowired
private RedisUtils redisUtil;
@Override
public int equipCategoryStatistics(String bizOrgCode, SourceTypeEnum sourceType, String categoryCode) {
// 计算处通用code,用来上下级匹配如12001010000->1200101
String treeCode = subStringZero(categoryCode);
Set<String> keys = redisUtil.getKeys(buildKey(bizOrgCode, sourceType.getCode(), treeCode));
if (keys.size() > 0) {
//求和
return this.sumNumber(keys);
} else {
//按照类型插入缓存
Object bean = SpringContextHelper.getBean(sourceType.getBeanName());
Method[] methods = bean.getClass().getDeclaredMethods();
for (Method method : methods) {
if (method.getName().equals(sourceType.getMethodName())) {
try {
method.invoke(bean);
} catch (Exception e) {
throw new RuntimeException("更新redis数据失败" + e.getMessage());
}
}
}
return this.sumNumber(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();
}
private String subStringZero(String categoryCode) {
String reverse = new StringBuffer(categoryCode).reverse().toString();
int noZero = Integer.parseInt(reverse);
return new StringBuffer(String.valueOf(noZero)).reverse().toString();
}
private String buildKey(String bizOrgCode, String sourceType, String treeCode) {
return bizOrgCode + "*_" + sourceType + "_" + treeCode + "*";
}
}
...@@ -604,4 +604,19 @@ ...@@ -604,4 +604,19 @@
from wl_car wc LEFT JOIN wl_car_property wcp on wc.id = wcp.car_id from wl_car wc LEFT JOIN wl_car_property wcp on wc.id = wcp.car_id
where wcp.equipment_index_key in ('FAS_Car_Video', 'FAS_Car_GIS'); where wcp.equipment_index_key in ('FAS_Car_Video', 'FAS_Car_GIS');
</select> </select>
<select id="queryCompanyCarStaData" resultType="java.util.Map">
SELECT
s.biz_org_code as bizOrgCode,
c.code as categoryCode,
count(1) as total
FROM
`wl_car` s,
wl_equipment e,
wl_equipment_category c
where
s.equipment_id = e.`id`
and e.category_id = c.id
and s.biz_org_code <![CDATA[<>]]> ''
GROUP BY s.biz_org_code ,c.code
</select>
</mapper> </mapper>
...@@ -1441,4 +1441,19 @@ ...@@ -1441,4 +1441,19 @@
WHERE WHERE
s.equipment_code = '92251100TZE44' s.equipment_code = '92251100TZE44'
</select> </select>
<select id="queryCompanyStaData" resultType="java.util.Map">
SELECT
s.biz_org_code as bizOrgCode,
c.code as categoryCode,
count(1) as total
FROM
`wl_equipment_specific` s,
wl_equipment e,
wl_equipment_category c
where
s.equipment_code = e.`code`
and e.category_id = c.id
and s.biz_org_code <![CDATA[<>]]> ''
GROUP BY s.biz_org_code ,c.code
</select>
</mapper> </mapper>
\ No newline at end of file
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