Compare commits

...

9 Commits

Author SHA1 Message Date
SjS
c7b9a3da9f Merge remote-tracking branch 'origin/master' 2025-04-27 16:01:30 +08:00
SjS
717b1f5648 广告待完成 2025-04-27 16:01:16 +08:00
磷叶
bd26ae2d34 Merge remote-tracking branch 'origin/master' 2025-04-27 15:23:41 +08:00
磷叶
a5127cd50b 协议、IOT推送 2025-04-27 15:23:34 +08:00
SjS
bd0a615254 更新 2025-04-27 15:23:12 +08:00
磷叶
d5b31fded3 Merge remote-tracking branch 'origin/wjh'
# Conflicts:
#	ruoyi-service/src/main/java/com/ruoyi/bst/agreement/mapper/AgreementMapper.xml
2025-04-27 15:10:21 +08:00
SjS
c71d11ca5c 广告命名规范与校验 2025-04-27 13:51:19 +08:00
SjS
cec8b55f51 协议完善 2025-04-27 11:42:05 +08:00
SjS
e7246d6029 协议新增分类 2025-04-27 11:08:49 +08:00
18 changed files with 158 additions and 40 deletions

View File

@ -48,6 +48,11 @@ public class Ad extends BaseEntity implements LogBizParam
@ApiModelProperty("运营区id")
private Long areaId;
@Excel(name = "广告状态")
@ApiModelProperty("广告状态")
@NotBlank(message = "广告状态不能为空", groups = {ValidGroup.Create.class})
private String status;
@Excel(name = "跳转链接")
@ApiModelProperty("跳转链接")
@NotBlank(message = "跳转链接不能为空", groups = {ValidGroup.Create.class})

View File

@ -9,8 +9,6 @@ public class AdVO extends Ad{
@ApiModelProperty("所属运营区")
private String areaName;
@ApiModelProperty("广告审核状态")
private String auditStatus;
@ApiModelProperty("审核人")
private String verifyName;

View File

@ -5,7 +5,7 @@ import lombok.Getter;
@Getter
@AllArgsConstructor
public enum AdBlong {
public enum AdBelong {
ADMIN("0", "管理员广告"),
STORE("1", "商户广告");

View File

@ -0,0 +1,30 @@
package com.ruoyi.bst.ad.domain.enums;
import com.ruoyi.bst.device.domain.enums.DeviceStatus;
import com.ruoyi.common.utils.collection.CollectionUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.List;
@Getter
@AllArgsConstructor
public enum AdStatus {
DISABLE("0", "禁用"),
ENABLE("1", "启用");
private final String code;
private final String name;
// 允许禁用的广告状态
public static List<String> canDisable() {
return CollectionUtils.map(AdStatus::getCode, ENABLE);
}
// 允许启用的广告状态
public static List<String> canEnable() {
return CollectionUtils.map(AdStatus::getCode, DISABLE);
}
}

View File

@ -19,6 +19,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="remark" column="remark" />
<result property="deleted" column="deleted" />
<result property="urlType" column="url_type" />
<result property="auditStatus" column="audit_status" />
<result property="status" column="status" />
</resultMap>
<sql id="selectAdVo">
@ -40,6 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bad.audit_status,
bad.verify_end_time,
bad.verify_by,
bad.status,
bad.verify_remark,
ba.name AS area_name,
su_verify.user_name as verify_name,
@ -62,6 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.deleted == null "> and bad.deleted = false</if>
<if test="query.auditStatus != null "> and bad.audit_status = #{query.auditStatus}</if>
<if test="query.urlType != null and query.urlType != ''"> and bad.url_type = #{query.urlType}</if>
<if test="query.status != null and query.status != ''"> and bad.status = #{query.status}</if>
${@com.ruoyi.framework.util.DataScopeUtil@dataScope(
null,
"bad.store_id,su.agent_id",
@ -116,6 +120,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">remark,</if>
<if test="deleted != null">deleted,</if>
<if test="urlType != null and urlType != ''">url_type,</if>
<if test="auditStatus != null and auditStatus != ''">audit_status,</if>
<if test="status != null and status != ''">status,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="storeId != null">#{storeId},</if>
@ -131,6 +137,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">#{remark},</if>
<if test="deleted != null">#{deleted},</if>
<if test="urlType != null and urlType != ''">#{urlType},</if>
<if test="auditStatus != null">#{auditStatus},</if>
<if test="status != null">#{status},</if>
</trim>
</insert>
@ -328,6 +336,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="data.auditStatus != null">audit_status = #{data.auditStatus},</if>
<if test="data.verifyEndTime != null">verify_end_time = #{data.verifyEndTime},</if>
<if test="data.verifyRemark != null">verify_remark = #{data.verifyRemark},</if>
<if test="data.status != null">status = #{data.status},</if>
</sql>
<delete id="deleteAdByAdId" parameterType="Long">

View File

@ -5,6 +5,7 @@ import com.ruoyi.bst.ad.domain.Ad;
import com.ruoyi.bst.ad.domain.AdVO;
import com.ruoyi.bst.ad.domain.AdQuery;
import com.ruoyi.bst.ad.domain.AdVerifyDTO;
import com.ruoyi.bst.device.domain.DeviceVO;
import com.ruoyi.bst.fault.domain.Fault;
import com.ruoyi.bst.fault.domain.FaultVO;
import com.ruoyi.bst.fault.domain.FaultVerifyDTO;
@ -72,4 +73,15 @@ public interface AdService
public int logicalDel(List<Long> adIds);
public int verify(AdVerifyDTO dto);
/**
* 启用
*/
public int enable(Long adId);
/**
* 禁用
*/
public int disable(Long adId);
}

View File

@ -1,8 +1,9 @@
package com.ruoyi.bst.ad.service.impl;
import com.ruoyi.bst.ad.domain.Ad;
import com.ruoyi.bst.ad.domain.enums.AdBlong;
import com.ruoyi.bst.ad.domain.enums.AdBelong;
import com.ruoyi.bst.ad.service.AdConverter;
import com.ruoyi.common.utils.ServiceUtil;
import org.springframework.stereotype.Service;
@ -12,20 +13,21 @@ public class AdConverterImpl implements AdConverter {
@Override
public Ad toPoByCreate(Ad data) {
if (data == null) {
if (data == null) {
return null;
}
Ad po = new Ad();
po.setBelong(data.getBelong());
// 基础信息
if (po.getBelong().equals(AdBlong.STORE.getCode())) {
if (po.getBelong().equals(AdBelong.STORE.getCode())) {
ServiceUtil.assertion(data.getAreaId()==null,"商户运营区不可以为空");
po.setAreaId(data.getAreaId());
}else{
po.setAreaId(null);
}
po.setType(data.getType());
po.setPicture(data.getPicture());
po.setStatus(data.getStatus());
po.setUrl(data.getUrl());
po.setUrlType(data.getUrlType());
po.setAuditStatus(data.getAuditStatus());
@ -40,13 +42,14 @@ public class AdConverterImpl implements AdConverter {
Ad po = new Ad();
// 基础信息
po.setBelong(data.getBelong());
if (po.getBelong().equals(AdBlong.STORE.getCode())) {
if (po.getBelong().equals(AdBelong.STORE.getCode())) {
po.setAreaId(data.getAreaId());
}else{
po.setAreaId(null);
}
po.setType(data.getType());
po.setPicture(data.getPicture());
po.setStatus(data.getStatus());
po.setUrl(data.getUrl());
po.setUrlType(data.getUrlType());
po.setAuditStatus(data.getAuditStatus());

View File

@ -1,17 +1,17 @@
package com.ruoyi.bst.ad.service.impl;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import com.ruoyi.bst.ad.domain.AdVerifyDTO;
import com.ruoyi.bst.ad.domain.enums.AdBlong;
import com.ruoyi.bst.ad.domain.enums.AdBelong;
import com.ruoyi.bst.ad.domain.enums.AdStatus;
import com.ruoyi.bst.ad.domain.enums.AdVerifyStatus;
import com.ruoyi.bst.ad.service.AdConverter;
import com.ruoyi.bst.area.domain.AreaVO;
import com.ruoyi.bst.area.service.AreaService;
import com.ruoyi.bst.device.domain.enums.DeviceStatus;
import com.ruoyi.bst.order.service.OrderService;
import com.ruoyi.common.core.domain.vo.UserVO;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServiceUtil;
@ -75,10 +75,10 @@ public class AdServiceImpl implements AdService {
public int insertAd(Ad ad) {
// 默认设置为商户广告
if (ad.getBelong() == null || ad.getBelong().equals("")) {
ad.setBelong(AdBlong.STORE.getCode());
ad.setBelong(AdBelong.STORE.getCode());
}
// 商户广告存在上限
if (ad.getBelong().equals(AdBlong.STORE.getCode())) {
if (ad.getBelong().equals(AdBelong.STORE.getCode())) {
AreaVO area = areaService.selectAreaById(ad.getAreaId());
ad.setStoreId(area.getUserId());
@ -152,13 +152,12 @@ public class AdServiceImpl implements AdService {
@Override
public int verify(AdVerifyDTO dto) {
// 查询故障申报
// 查询广告
AdVO ad = this.selectAdByAdId(dto.getId());
ServiceUtil.assertion(ad == null, "当前广告信息不存在", dto.getId());
ServiceUtil.assertion(!AdVerifyStatus.canVerify().contains(ad.getAuditStatus()), "ID为%s的广告当前不允许审核", dto.getId());
// 更新故障申报状态
boolean pass = dto.getPass() != null && dto.getPass();
// 更新故障申报状态
// 更新广告状态
Ad data = new Ad();
data.setAuditStatus(pass ? AdVerifyStatus.PASSED.getCode() : AdVerifyStatus.REJECTED.getCode());
data.setVerifyBy(SecurityUtils.getUserId());
@ -172,4 +171,22 @@ public class AdServiceImpl implements AdService {
return rows;
}
@Override
public int enable(Long adId) {
AdVO ad = this.selectAdByAdId(adId);
ServiceUtil.assertion(ad == null, "当前广告信息不存在", adId);
ServiceUtil.assertion(!AdStatus.canEnable().contains(ad.getStatus()), "广告%s当前状态不允许启用", adId);
// 更新广告状态
return 1;
}
@Override
public int disable(Long adId) {
AdVO ad = this.selectAdByAdId(adId);
ServiceUtil.assertion(ad == null, "当前广告信息不存在", adId);
ServiceUtil.assertion(!AdStatus.canDisable().contains(ad.getStatus()), "广告%s当前状态不允许启用", adId);
// 更新广告状态
return 1;
}
}

View File

@ -6,8 +6,7 @@ import lombok.Data;
@Data
public class AgreementVO extends Agreement{
@ApiModelProperty("商户ID")
@ApiModelProperty("运营商ID")
private Long storeId;
@ApiModelProperty("商户名")
@ -16,7 +15,7 @@ public class AgreementVO extends Agreement{
@ApiModelProperty("运营区")
private String areaName;
@ApiModelProperty("运营商ID")
@ApiModelProperty("代理商ID")
private Long agentId;
}

View File

@ -20,7 +20,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bag.update_time,
su.nick_name as user_name,
ba.name as area_name,
ba.user_id as store_id
ba.user_id as store_id,
su.agent_id as agent_id
from <include refid="searchTables"/>
</sql>
@ -48,7 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
${@com.ruoyi.framework.util.DataScopeUtil@dataScope(
null,
"ba.user_id",
"ba.user_id,su.agent_id",
null,
null,
query.scope

View File

@ -5,6 +5,7 @@ import com.ruoyi.bst.agreement.domain.AgreementVO;
import com.ruoyi.bst.agreement.mapper.AgreementMapper;
import com.ruoyi.bst.agreement.service.AgreementValidator;
import com.ruoyi.bst.area.domain.AreaVO;
import com.ruoyi.bst.area.service.AreaService;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.collection.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -18,6 +19,8 @@ public class AgreementValidatorImpl implements AgreementValidator {
@Autowired
private AgreementMapper agreementMapper;
@Autowired
private AreaService areaService;
@Override
public boolean canEdit(Long agreementId) {

View File

@ -1,6 +1,5 @@
package com.ruoyi.iot.service.impl;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
@ -70,10 +69,6 @@ public class IotConverterImpl implements IotConverter {
if (sys == null) {
return;
}
// 旧版硬件BUG电压超过100V的需要除以10
if (sys.getBat() != null && sys.getBat().compareTo(BigDecimal.valueOf(100)) >= 0) {
sys.setBat(sys.getBat().divide(BigDecimal.valueOf(10), 2, BigDecimal.ROUND_HALF_UP));
}
device.setSys(sys);
}

View File

@ -89,6 +89,12 @@ public class IotReceiveServiceImpl implements IotReceiveService {
IotDeviceSysInfo sys = IotUtil.toSysInfo(msg.getValue());
LocalDateTime at = DateUtils.toLocalDateTime(msg.getAt());
// 0,0定位不处理
if (MathUtils.equals(sys.getLon(), BigDecimal.ZERO) && MathUtils.equals(sys.getLat(), BigDecimal.ZERO)) {
log.info("设备{}定位异常:{},{},不处理", msg.getDevName(), sys.getLon(), sys.getLat());
return;
}
// 处理设备定位BUG若出现BUG则重启设备
int handle = this.handleDeviceLocationBug(device, sys, at);
if (handle == 1) {
@ -136,10 +142,6 @@ public class IotReceiveServiceImpl implements IotReceiveService {
if (device == null || StringUtils.isBlank(device.getMac()) || device.getLastLocationTime() == null || at == null) {
return 0;
}
// 0,0定位不处理
if (MathUtils.equals(sys.getLon(), BigDecimal.ZERO) && MathUtils.equals(sys.getLat(), BigDecimal.ZERO)) {
return 0;
}
// 相差一分钟以上的消息不做处理
Duration duration = Duration.between(at, LocalDateTime.now());
if (duration.getSeconds() > 60) {

View File

@ -1,6 +1,7 @@
package com.ruoyi.iot.util;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
@ -220,6 +221,13 @@ public class IotUtil {
if (value == null) {
return null;
}
return JSON.parseObject(value.toString(), IotDeviceSysInfo.class);
IotDeviceSysInfo sys = JSON.parseObject(value.toString(), IotDeviceSysInfo.class);
// 旧版硬件BUG电压超过100V的需要除以10
if (sys.getBat() != null && sys.getBat().compareTo(BigDecimal.valueOf(100)) >= 0) {
sys.setBat(sys.getBat().divide(BigDecimal.valueOf(10), 2, BigDecimal.ROUND_HALF_UP));
}
return sys;
}
}

View File

@ -2,7 +2,8 @@ package com.ruoyi.web.app;
import com.ruoyi.bst.ad.domain.AdQuery;
import com.ruoyi.bst.ad.domain.AdVO;
import com.ruoyi.bst.ad.domain.enums.AdBlong;
import com.ruoyi.bst.ad.domain.enums.AdBelong;
import com.ruoyi.bst.ad.domain.enums.AdStatus;
import com.ruoyi.bst.ad.domain.enums.AdVerifyStatus;
import com.ruoyi.common.core.domain.vo.UserVO;
import com.ruoyi.system.user.service.UserService;
@ -36,14 +37,14 @@ public class AppAdController extends BaseController {
@Anonymous
public AjaxResult getAd(AdQuery query) {
query.setAuditStatus(AdVerifyStatus.PASSED.getCode());
query.setStatus(AdStatus.ENABLE.getCode());
List<AdVO> list = new ArrayList<>();
// 查询所属运营区的广告
UserVO user = userService.selectUserById(getUserId());
if (user.getAreaId() != null) {
query.setAreaId(user.getAreaId());
query.setBelong(AdBlong.STORE.getCode());
query.setBelong(AdBelong.STORE.getCode());
List<AdVO> areaAdVOList = adService.selectAdList(query);
if (areaAdVOList != null) {
list.addAll(areaAdVOList);
@ -52,7 +53,7 @@ public class AppAdController extends BaseController {
// 查询管理员发布的广告
query.setAreaId(null);
query.setBelong(AdBlong.ADMIN.getCode());
query.setBelong(AdBelong.ADMIN.getCode());
List<AdVO> adminAdVOList = adService.selectAdList(query);
if (adminAdVOList != null) {
list.addAll(adminAdVOList);

View File

@ -2,9 +2,12 @@ package com.ruoyi.web.app;
import com.github.pagehelper.PageHelper;
import com.ruoyi.bst.agreement.domain.AgreementQuery;
import com.ruoyi.bst.agreement.domain.AgreementVO;
import com.ruoyi.bst.agreement.domain.enums.AgreementContentType;
import com.ruoyi.bst.agreement.service.AgreementService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.collection.CollectionUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -21,16 +24,15 @@ public class AppAgreementController extends BaseController {
public AjaxResult getAgreement(AgreementQuery query) {
PageHelper.startPage(1, 1);
PageHelper.orderBy("create_time desc");
if (query.getContentType()==null) {
return AjaxResult.error("内容类型不能为空");
}
query.setContentType(AgreementContentType.TEXT.getCode());
if (query.getAgreementType()==null) {
return AjaxResult.error("协议类型不能为空");
}
if (query.getAreaId()==null) {
return AjaxResult.error("运营区不能为空");
}
return success(agreementService.selectAgreementList(query));
AgreementVO agreementVO = CollectionUtils.firstElement(agreementService.selectAgreementList(query));
return success(agreementVO);
}

View File

@ -29,6 +29,7 @@ public class AppCustomerServiceController extends BaseController {
startPage();
startOrderBy();
query.setIsEnabled(CustomerServiceStatus.ENABLE.getStatus());
query.setDeleted(false);
return getDataTable(customerServiceService.selectCustomerServiceList(query));
}

View File

@ -4,6 +4,7 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.bst.ad.domain.enums.AdBelong;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
@ -103,6 +104,7 @@ public class AdController extends BaseController
ad.setAuditStatus("2");
} else {
ad.setAuditStatus("1");
ad.setBelong(AdBelong.STORE.getCode());
}
ad = adConverter.toPoByCreate(ad);
return toAjax(adService.insertAd(ad));
@ -154,4 +156,34 @@ public class AdController extends BaseController
return toAjax(adService.verify(dto));
}
@PreAuthorize("@ss.hasPermi('bst:ad:enable')")
@Log(title = "广告启用", businessType = BusinessType.OTHER, bizIdName = "arg0", bizType = LogBizType.AD)
@ApiOperation("广告启用")
@PutMapping("/enable")
public AjaxResult enableAd(@RequestBody Long id) {
if (!adValidator.canEdit(id)){
return error("您无权启用id为"+ id +"的广告");
}
int count = adService.enable(id);
if (count == 0) {
return error("启用失败");
}
return toAjax(count);
}
@PreAuthorize("@ss.hasPermi('bst:ad:disable')")
@Log(title = "广告禁用", businessType = BusinessType.OTHER, bizIdName = "arg0", bizType = LogBizType.AD)
@ApiOperation("广告禁用")
@PutMapping("/disable")
public AjaxResult disableAd(@RequestBody Long id) {
if (!adValidator.canEdit(id)){
return error("您无权禁用id为"+ id +"的广告");
}
int count = adService.disable(id);
if (count == 0) {
return error("禁用失败");
}
return toAjax(count);
}
}