|
@@ -7,6 +7,7 @@ import com.ruoyi.demo.entity.ManageType;
|
|
|
import com.ruoyi.demo.entity.StoreWd;
|
|
|
import com.ruoyi.demo.entity.TopologicalStoreWd;
|
|
|
import com.ruoyi.demo.entity.WdInfo;
|
|
|
+import com.ruoyi.demo.entity.bo.Histogram;
|
|
|
import com.ruoyi.demo.entity.bo.StoreWdCategoryCount;
|
|
|
import com.ruoyi.demo.entity.bo.StoreWdCategoryCountBody;
|
|
|
import com.ruoyi.demo.entity.vo.TopologicalWdAceeptVo;
|
|
@@ -50,7 +51,8 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
|
|
|
QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
|
|
|
queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
|
|
|
WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
|
|
|
-
|
|
|
+ if (wdInfo1 == null)
|
|
|
+ return new ArrayList<>();
|
|
|
//2.根据中心网点找到周边网点Id
|
|
|
// 以经纬度为中心,获取半径不超过最大距离的所有元素
|
|
|
Point point = new Point(wdInfo1.getLng().doubleValue(),wdInfo1.getLat().doubleValue());
|
|
@@ -109,7 +111,8 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
|
|
|
QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
|
|
|
queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
|
|
|
WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
|
|
|
-
|
|
|
+ if (wdInfo1 == null)
|
|
|
+ return new ArrayList<>();
|
|
|
//2.根据中心网点找到周边网点Id
|
|
|
// 以经纬度为中心,获取半径不超过最大距离的所有元素
|
|
|
Point point = new Point(wdInfo1.getLng().doubleValue(),wdInfo1.getLat().doubleValue());
|
|
@@ -191,4 +194,133 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
|
|
|
|
|
|
return storeWdCategoryCounts;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Histogram> storeHistogram(TopologicalWdAceeptVo topologicalWdAceeptVo) {
|
|
|
+ //1.根据中心网点Id找到网点详细信息
|
|
|
+ QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
|
|
|
+ queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
|
|
|
+ WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
|
|
|
+ if (wdInfo1 == null)
|
|
|
+ return new ArrayList<>();
|
|
|
+ //2.根据中心网点找到周边网点Id
|
|
|
+ // 以经纬度为中心,获取半径不超过最大距离的所有元素
|
|
|
+ Point point = new Point(wdInfo1.getLng().doubleValue(),wdInfo1.getLat().doubleValue());
|
|
|
+ //半径范围
|
|
|
+ Distance distance = new Distance(topologicalWdAceeptVo.getRadius(), RedisGeoCommands.DistanceUnit.METERS);
|
|
|
+ //圆
|
|
|
+ Circle circle = new Circle(point, distance);
|
|
|
+ GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(wdInfo1.getAddrCode().substring(0, 4)).radius(circle);
|
|
|
+ //周边网点Id
|
|
|
+ List<String> aroundWdId = new ArrayList<>();
|
|
|
+ radius.getContent().stream().forEach(item -> {
|
|
|
+ //记录网点坐标及距离
|
|
|
+ aroundWdId.add((String) item.getContent().getName());
|
|
|
+ });
|
|
|
+
|
|
|
+ if (aroundWdId.isEmpty())
|
|
|
+ return new ArrayList<>();
|
|
|
+
|
|
|
+ QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.select("type_code_by","count(*) as audit");
|
|
|
+ queryWrapper.and(queryWrapper2 -> {
|
|
|
+ queryWrapper2.eq("wd_type_code","1");
|
|
|
+ });
|
|
|
+ queryWrapper.and(queryWrapper2 -> {
|
|
|
+ queryWrapper2.isNotNull("type_code_by");
|
|
|
+ });
|
|
|
+ queryWrapper.groupBy("type_code_by");
|
|
|
+ List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
|
|
|
+
|
|
|
+ int total = 0;
|
|
|
+ HashMap<String,Integer> hashMap = new HashMap<>();
|
|
|
+ for (WdInfo wdInfo : wdInfos) {
|
|
|
+ if(wdInfo.getTypeCodeBy() == null)
|
|
|
+ continue;
|
|
|
+ String typeCodeBy = wdInfo.getTypeCodeBy().substring(0,2);
|
|
|
+ Integer integer = hashMap.get(typeCodeBy);
|
|
|
+ if (integer == null){
|
|
|
+ hashMap.put(typeCodeBy,wdInfo.getAudit());
|
|
|
+ }else {
|
|
|
+ hashMap.put(typeCodeBy,hashMap.get(typeCodeBy)+wdInfo.getAudit());
|
|
|
+ }
|
|
|
+ total+=wdInfo.getAudit();
|
|
|
+ }
|
|
|
+
|
|
|
+ ArrayList<Histogram> list = new ArrayList<>();
|
|
|
+ for (String s : hashMap.keySet()) {
|
|
|
+ Integer integer = hashMap.get(s);
|
|
|
+ String initTypeByMap = initMapUtil.getInitTypeByMap(s + "0000").replace(":","");
|
|
|
+ Histogram histogram = new Histogram();
|
|
|
+ histogram.setName(initTypeByMap);
|
|
|
+ histogram.setCount(integer);
|
|
|
+ list.add(histogram);
|
|
|
+ }
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Histogram> perCapitaConsumpHistogram(TopologicalWdAceeptVo topologicalWdAceeptVo) {
|
|
|
+ //1.根据中心网点Id找到网点详细信息
|
|
|
+ QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
|
|
|
+ queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
|
|
|
+ WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
|
|
|
+ if (wdInfo1 == null)
|
|
|
+ return new ArrayList<>();
|
|
|
+ //2.根据中心网点找到周边网点Id
|
|
|
+ // 以经纬度为中心,获取半径不超过最大距离的所有元素
|
|
|
+ Point point = new Point(wdInfo1.getLng().doubleValue(),wdInfo1.getLat().doubleValue());
|
|
|
+ //半径范围
|
|
|
+ Distance distance = new Distance(topologicalWdAceeptVo.getRadius(), RedisGeoCommands.DistanceUnit.METERS);
|
|
|
+ //圆
|
|
|
+ Circle circle = new Circle(point, distance);
|
|
|
+ GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(wdInfo1.getAddrCode().substring(0, 4)).radius(circle);
|
|
|
+ //周边网点Id
|
|
|
+ List<String> aroundWdId = new ArrayList<>();
|
|
|
+ radius.getContent().stream().forEach(item -> {
|
|
|
+ //记录网点坐标及距离
|
|
|
+ aroundWdId.add((String) item.getContent().getName());
|
|
|
+ });
|
|
|
+
|
|
|
+ if (aroundWdId.isEmpty())
|
|
|
+ return new ArrayList<>();
|
|
|
+
|
|
|
+ QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.select("wd_id");
|
|
|
+ queryWrapper.and(queryWrapper2 -> {
|
|
|
+ queryWrapper2.eq("wd_type_code","1");
|
|
|
+ });
|
|
|
+ List<StoreWd> storeWds = storeWdDao.perCapitaConsumpAnalyse(queryWrapper);
|
|
|
+ HashMap<String, Integer> hashMap = new HashMap<>();
|
|
|
+ hashMap.put("0~20",0);
|
|
|
+ hashMap.put("20~50",0);
|
|
|
+ hashMap.put("50~100",0);
|
|
|
+ hashMap.put("100~200",0);
|
|
|
+ hashMap.put("200以上",0);
|
|
|
+ for (StoreWd storeWd : storeWds) {
|
|
|
+ if (storeWd.getPerCapitaConsumption() != null){
|
|
|
+ if (storeWd.getPerCapitaConsumption() >= 0 && storeWd.getPerCapitaConsumption()<20){
|
|
|
+ hashMap.put("0~20",hashMap.get("0~20")+1);
|
|
|
+ }else if(storeWd.getPerCapitaConsumption() >= 20 && storeWd.getPerCapitaConsumption()<50){
|
|
|
+ hashMap.put("20~50",hashMap.get("20~50")+1);
|
|
|
+ }else if(storeWd.getPerCapitaConsumption() >= 50 && storeWd.getPerCapitaConsumption()< 100){
|
|
|
+ hashMap.put("50~100",hashMap.get("50~100")+1);
|
|
|
+ }else if(storeWd.getPerCapitaConsumption() >= 100 && storeWd.getPerCapitaConsumption()< 200){
|
|
|
+ hashMap.put("100~200",hashMap.get("100~200")+1);
|
|
|
+ }else {
|
|
|
+ hashMap.put("200以上",hashMap.get("200以上")+1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ArrayList<Histogram> list = new ArrayList<>();
|
|
|
+ for (String s : hashMap.keySet()) {
|
|
|
+ Histogram histogram = new Histogram();
|
|
|
+ histogram.setName(s);
|
|
|
+ histogram.setCount(hashMap.get(s));
|
|
|
+ list.add(histogram);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
}
|