|
@@ -1,21 +1,14 @@
|
|
|
package com.gis.cms.service.impl;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.gis.cms.entity.po.*;
|
|
|
-import com.gis.cms.entity.vo.ParkVo;
|
|
|
import com.gis.cms.service.*;
|
|
|
-import com.gis.common.constant.TypeCode;
|
|
|
import com.gis.common.util.RedisCache;
|
|
|
import com.gis.common.util.Result;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.math.RoundingMode;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
-import java.util.Set;
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -27,7 +20,21 @@ public class WebServiceImpl implements WebService {
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
- LeaderService aerialService;
|
|
|
+ LeaderService leaderService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ GoodsService goodsService;
|
|
|
+ @Autowired
|
|
|
+ VideoService videoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ImgService imgService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ MusicService musicService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ StudentService studentService;
|
|
|
|
|
|
@Autowired
|
|
|
RedisCache redisCache;
|
|
@@ -61,58 +68,46 @@ public class WebServiceImpl implements WebService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 计算json百分比
|
|
|
- * @param dJson
|
|
|
- */
|
|
|
- private void calcJsonPct(JSONObject dJson){
|
|
|
- Set<String> keySet = dJson.keySet();
|
|
|
- // 总数
|
|
|
- int sum = 0;
|
|
|
- for (String s : keySet) {
|
|
|
- String str = dJson.getString(s);
|
|
|
- sum += Integer.valueOf(str);
|
|
|
- }
|
|
|
- log.info("百分比sum: {}", sum);
|
|
|
|
|
|
- // 赋值
|
|
|
- for (String s : keySet) {
|
|
|
- String str = dJson.getString(s);
|
|
|
- dJson.put(s, divide(str, sum));
|
|
|
+ @Override
|
|
|
+ public Result saveVisit(String type, Long id) {
|
|
|
+ List<String> list = Arrays.asList("goods", "leader","student", "video", "img", "music");
|
|
|
+ if (!list.contains(type)){
|
|
|
+ return Result.failure("非法类型");
|
|
|
}
|
|
|
|
|
|
+ switch (type){
|
|
|
+ case "goods":
|
|
|
+ goodsService.setVisit(id);
|
|
|
+ break;
|
|
|
|
|
|
- }
|
|
|
+ case "leader":
|
|
|
+ leaderService.setVisit(id);
|
|
|
+ break;
|
|
|
|
|
|
- // 计算百分比
|
|
|
- private void calcPct(ParkVo parkVo){
|
|
|
- String apartment = parkVo.getApartment();
|
|
|
- String complexBuilding = parkVo.getComplexBuilding();
|
|
|
- String exchangeCentre = parkVo.getExchangeCentre();
|
|
|
- String scientificBuilding = parkVo.getScientificBuilding();
|
|
|
- String serviceCentre = parkVo.getServiceCentre();
|
|
|
+ case "student":
|
|
|
+ studentService.setVisit(id);
|
|
|
+ break;
|
|
|
|
|
|
- int total = Integer.valueOf(apartment) + Integer.valueOf(complexBuilding) +Integer.valueOf(exchangeCentre) +Integer.valueOf(scientificBuilding) +Integer.valueOf(serviceCentre);
|
|
|
+ case "video":
|
|
|
+ videoService.setVisit(id);
|
|
|
+ break;
|
|
|
|
|
|
+ case "img":
|
|
|
+ imgService.setVisit(id);
|
|
|
+ break;
|
|
|
|
|
|
- parkVo.setApartment(divide(parkVo.getApartment(), total));
|
|
|
- parkVo.setComplexBuilding(divide(parkVo.getComplexBuilding(), total));
|
|
|
- parkVo.setExchangeCentre(divide(parkVo.getExchangeCentre(), total));
|
|
|
- parkVo.setScientificBuilding(divide(parkVo.getScientificBuilding(), total));
|
|
|
- parkVo.setServiceCentre(divide(parkVo.getServiceCentre(), total));
|
|
|
- }
|
|
|
+ case "music":
|
|
|
+ musicService.setVisit(id);
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- *
|
|
|
- * @param param 除数
|
|
|
- * @param n 被除数
|
|
|
- * @return
|
|
|
- */
|
|
|
- private String divide(String param, int n){
|
|
|
- BigDecimal num = new BigDecimal(param);
|
|
|
- BigDecimal dividend = new BigDecimal(n);
|
|
|
- BigDecimal divide = num.divide(dividend, 2, RoundingMode.HALF_UP);
|
|
|
- BigDecimal multiply = divide.multiply(new BigDecimal(100));
|
|
|
- return multiply.toString();
|
|
|
+ return Result.success();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|