Переглянути джерело

feat(app): 计算并展示场地好评率和评论数

- 在 AppHomeServiceImpl 中添加计算好评率和评论数的方法
- 在 PlaceVO 和 SearchVO 中更新好评率和评论数的数据类型
- 优化 AppDeviceController 中的设备添加和编辑逻辑
-调整门禁通知接口参数类型
SheepHy 1 місяць тому
батько
коміт
be7fef38c6

+ 12 - 4
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/AppHomeServiceImpl.java

@@ -11,7 +11,6 @@ import org.jeecg.modules.app.vo.*;
 import org.jeecg.modules.system.app.entity.*;
 import org.jeecg.modules.system.app.mapper.*;
 import org.jeecg.modules.system.entity.SysUser;
-import org.jeecg.modules.system.mapper.SysDepartMapper;
 import org.jeecg.modules.system.mapper.SysUserMapper;
 import org.jeecg.modules.system.util.PositionUtil;
 import org.springframework.beans.BeanUtils;
@@ -34,8 +33,6 @@ public class AppHomeServiceImpl implements IAppHomeService {
     @Resource
     private SysUserMapper sysUserMapper;
     @Resource
-    private SysDepartMapper sysDepartMapper;
-    @Resource
     private AppSiteMapper appSiteMapper;
     @Resource
     private AppCategoryMapper appCategoryMapper;
@@ -51,6 +48,8 @@ public class AppHomeServiceImpl implements IAppHomeService {
     private AppGamePriceRulesMapper appGamePriceRulesMapper;
     @Resource
     private AppOrderMapper appOrderMapper;
+    @Resource
+    private EvaluateMapper evaluateMapper;
 
     @Override
     public HomeVO homeInfo() {
@@ -194,8 +193,12 @@ public class AppHomeServiceImpl implements IAppHomeService {
                 }else{
                     placeVO.setKm(0.0);
                 }
+                long scoreNum = evaluateMapper.findByScoreNum(placeVO.getId());
+                long goodScoreNum = evaluateMapper.findByGoodScoreNum(placeVO.getId());
                 placeVO.setCategory(getCategoryName(placeVO.getCategoryId()));
                 placeVO.setTicketWhether(ticketWhether);
+                placeVO.setGoodRate(goodScoreNumRate(goodScoreNum, scoreNum));
+                placeVO.setComments(scoreNum);
             });
         }
 
@@ -362,7 +365,12 @@ public class AppHomeServiceImpl implements IAppHomeService {
         });
         return page;
     }
-    
+
+    public static long goodScoreNumRate(Long goodScoreNum, Long scoreNum) {
+        // 计算平均数
+        return scoreNum == 0 ? 0 : (long) (goodScoreNum * 100.00 / scoreNum);
+    }
+
     /** 
      * @Author SheepHy
      * @Description

+ 2 - 2
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/vo/PlaceVO.java

@@ -19,9 +19,9 @@ public class PlaceVO extends Page<PlaceVO> {
     @Schema(description = "场地名称")
     private String name;
     @Schema(description = "好评率")
-    private BigDecimal goodRate;
+    private long goodRate;
     @Schema(description = "评论数")
-    private String comments;
+    private long comments;
     @Schema(description = "地址")
     private String address;
     @Schema(description = "图片")

+ 2 - 2
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/vo/SearchVO.java

@@ -130,9 +130,9 @@ public class SearchVO{
         @Schema(description = "图片")
         private String cover;
         @Schema(description = "好评率")
-        private BigDecimal goodRate;
+        private long goodRate;
         @Schema(description = "评论数")
-        private String comments;
+        private long comments;
         @Schema(description = "退款类型")
         private int refundType;
         @Schema(description = "地址")

+ 10 - 6
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/controller/AppDeviceController.java

@@ -14,7 +14,6 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.query.QueryGenerator;
-import org.jeecg.modules.system.app.dto.evaluate.EventRequestDTO;
 import org.jeecg.modules.system.app.entity.AppDevice;
 import org.jeecg.modules.system.app.mapper.AppSiteMapper;
 import org.jeecg.modules.system.app.service.IAppDeviceService;
@@ -70,7 +69,7 @@ public class AppDeviceController extends JeecgController<AppDevice, IAppDeviceSe
 			return Result.OK(pageList);
 		}
 		pageList.getRecords().forEach(item->{
-			if(!item.getSiteId().isEmpty()){
+			if(null != item.getSiteId() && !item.getSiteId().isEmpty()){
 				item.setSiteName(appSiteMapper.selectById(item.getSiteId()).getName());
 			}
 		});
@@ -88,9 +87,7 @@ public class AppDeviceController extends JeecgController<AppDevice, IAppDeviceSe
 	@Transactional
 	public Result<String> add(@RequestBody AppDevice appDevice){
 		if(AppDeviceService.getOne(Wrappers.<AppDevice>lambdaQuery()
-				.eq(AppDevice::getDeviceSerial,appDevice.getDeviceSerial())
-				.eq(AppDevice::getDeviceNo,appDevice.getDeviceNo())
-				.eq(AppDevice::getDeviceType,appDevice.getDeviceType())) != null) {
+				.eq(AppDevice::getDeviceSerial,appDevice.getDeviceSerial())) != null) {
 			return Result.error("设备已存在!");
 		}
 		AppDeviceService.save(appDevice);
@@ -109,6 +106,12 @@ public class AppDeviceController extends JeecgController<AppDevice, IAppDeviceSe
 	@Transactional
 	public Result<String> edit(@RequestBody AppDevice appDevice) {
 		appDevice.setOrgCode(appSiteMapper.selectById(appDevice.getSiteId()).getOrgCode());
+		if(AppDeviceService.getOne(Wrappers.<AppDevice>lambdaQuery()
+				.eq(AppDevice::getDeviceSerial,appDevice.getDeviceSerial())
+				.eq(AppDevice::getDeviceNo,appDevice.getDeviceNo())
+				.eq(AppDevice::getDeviceType,appDevice.getDeviceType())) != null) {
+			return Result.error("设备已存在!");
+		}
 		AppDeviceService.updateById(appDevice);
 		if(appDevice.getDeviceSerial() != null && appDevice.getValidateCode() != null && appDevice.getSiteId() != null){
 			String addDevice = addDevice(appDevice.getDeviceSerial(), appDevice.getValidateCode());
@@ -200,7 +203,8 @@ public class AppDeviceController extends JeecgController<AppDevice, IAppDeviceSe
     }
 
 	@PostMapping(value = "/notice")
-	public Result<String> doorOpeningNotice(@RequestBody EventRequestDTO eventRequestDTO) {
+	public Result<String> doorOpeningNotice(@RequestBody Object json) {
+		System.out.println("海康回调通知: " + json);
 		return Result.OK(null);
 	}