This commit is contained in:
墨大叔 2024-07-09 15:10:40 +08:00
parent 1a2128642f
commit c6edec8083
18 changed files with 84 additions and 124 deletions

View File

@ -11,7 +11,7 @@ import com.ruoyi.ss.device.domain.SmDeviceQuery;
import com.ruoyi.ss.device.domain.enums.DeviceOnlineStatus;
import com.ruoyi.ss.device.service.ISmDeviceService;
import com.ruoyi.ss.model.domain.SmModelQuery;
import com.ruoyi.ss.model.service.ISmModelService;
import com.ruoyi.ss.model.service.ModelService;
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillStatus;
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
@ -43,7 +43,7 @@ public class SmBusinessRecordServiceImpl implements ISmBusinessRecordService
private ISmUserService userService;
@Autowired
private ISmModelService modelService;
private ModelService modelService;
@Autowired
private TransactionBillService transactionBillService;

View File

@ -7,6 +7,7 @@ package com.ruoyi.ss.device.domain.enums;
public enum DeviceGroupByTable {
sd, // 设备表
ss // 店铺表
ss, // 店铺表
su, // 用户表
}

View File

@ -176,6 +176,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
from sm_device sd
left join sm_store ss on ss.store_id = sd.store_id
left join sm_user su on su.user_id = sd.user_id
<where>
<include refid="searchCondition"/>
</where>

View File

@ -22,7 +22,7 @@ import com.ruoyi.ss.device.service.DeviceValidator;
import com.ruoyi.ss.device.service.ISmDeviceService;
import com.ruoyi.ss.deviceBindRecord.service.ISmDeviceBindRecordService;
import com.ruoyi.ss.model.domain.SmModelVo;
import com.ruoyi.ss.model.service.ISmModelService;
import com.ruoyi.ss.model.service.ModelService;
import com.ruoyi.ss.record.time.service.IRecordTimeService;
import com.ruoyi.ss.record.time.service.RecordTimeConverter;
import com.ruoyi.ss.resetRecord.service.ISmResetRecordService;
@ -66,9 +66,6 @@ public class SmDeviceServiceImpl implements ISmDeviceService
@Autowired
private ISmDeviceBindRecordService smDeviceBindRecordService;
@Autowired
private ISmResetRecordService smResetRecordService;
@Autowired
private ScheduledExecutorService scheduledExecutorService;
@ -88,7 +85,7 @@ public class SmDeviceServiceImpl implements ISmDeviceService
private RecordTimeConverter recordTimeConverter;
@Autowired
private ISmModelService smModelService;
private ModelService smModelService;
@Autowired
private ISmUserService userService;
@ -749,8 +746,9 @@ public class SmDeviceServiceImpl implements ISmDeviceService
boolean create = iotService.create(smDevice.getMac());
ServiceUtil.assertion(!create, "创建OneNet设备失败");
}
log.info("select model in:{}", deviceInfo.getModel());
SmModelVo model = smModelService.selectByIotModel(deviceInfo.getModel());
SmModelVo model = smModelService.selectByModel(deviceInfo.getModel());
IotDeviceInfo finalDeviceInfo = deviceInfo;
Integer result = transactionTemplate.execute(status -> {
@ -761,7 +759,7 @@ public class SmDeviceServiceImpl implements ISmDeviceService
log.info("model is null");
int addModel = smModelService.addInitModel(finalDeviceInfo);
ServiceUtil.assertion(addModel != 1, "添加设备型号失败");
finalModel = smModelService.selectByIotModel(finalDeviceInfo.getModel());
finalModel = smModelService.selectByModel(finalDeviceInfo.getModel());
}
// 添加设备

View File

@ -43,18 +43,6 @@ public class SmModel extends BaseEntity
@ApiModelProperty("图片")
private String picture;
/** 识别码 */
@Excel(name = "识别码")
@ApiModelProperty("识别码")
@NotNull(message = "识别码不允许为空", groups = {ValidGroup.Create.class})
private String idCode;
/** 硬件版本 */
@Excel(name = "硬件版本")
@ApiModelProperty("硬件版本")
@NotNull(message = "硬件版本不允许为空", groups = {ValidGroup.Create.class})
private Long versionId;
/** 产品介绍 */
@Excel(name = "产品介绍")
@ApiModelProperty("硬件版本")

View File

@ -15,17 +15,18 @@ public class SmModelBO extends SmModel {
bo.setModel(getModel());
bo.setTags(getTags());
bo.setPicture(getPicture());
bo.setIdCode(getIdCode());
bo.setIntroduce(getIntroduce());
bo.setRemark(getRemark());
bo.setVersionId(getVersionId());
return bo;
}
// 过滤可更新的字段
public SmModelBO filterUpdate() {
SmModelBO bo = new SmModelBO();
bo.setModelId(getModelId());
bo.setModelName(getModelName());
bo.setModel(getModel());
bo.setTags(getTags());
bo.setPicture(getPicture());
bo.setIntroduce(getIntroduce());
bo.setRemark(getRemark());

View File

@ -4,22 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.ss.model.mapper.SmModelMapper">
<resultMap type="com.ruoyi.ss.model.domain.SmModelVo" id="SmModelResult">
<result property="modelId" column="model_id" />
<result property="modelName" column="model_name" />
<result property="model" column="model" />
<result property="picture" column="picture" />
<result property="idCode" column="id_code" />
<result property="versionId" column="version_id" />
<result property="introduce" column="introduce" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="activationCount" column="activation_count"/>
<result property="onlineCount" column="online_count"/>
<result property="deleted" column="deleted"/>
<resultMap type="com.ruoyi.ss.model.domain.SmModelVo" id="SmModelResult" autoMapping="true">
<result property="tags" column="tags" typeHandler="com.ruoyi.system.mapper.typehandler.StringSplitListTypeHandler"/>
</resultMap>
@ -28,8 +13,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sm.model_name,
sm.model,
sm.picture,
sm.id_code,
sm.version_id,
sm.introduce,
sm.create_by,
sm.create_time,
@ -47,15 +30,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="searchCondition">
<if test="modelName != null and modelName != ''"> and sm.model_name like concat('%', #{modelName}, '%')</if>
<if test="model != null and model != ''"> and sm.model = #{model}</if>
<if test="idCode != null and idCode != ''"> and sm.id_code = #{idCode}</if>
<if test="versionId != null "> and sm.version_id = #{versionId}</if>
<if test="deleted == null">and sm.deleted = false</if>
<if test="deleted != null">and sm.deleted = #{deleted}</if>
</sql>
<select id="selectSmModelList" parameterType="SmModelQuery" resultMap="SmModelResult">
<include refid="selectSmModelVo"/>
<where>
<include refid="searchCondition"/>
and sm.deleted = false
</where>
group by sm.model_id
</select>
@ -71,7 +53,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from sm_model sm
<where>
<include refid="searchCondition"/>
and sm.deleted = false
</where>
</select>
@ -81,8 +62,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="modelName != null">model_name,</if>
<if test="model != null">model,</if>
<if test="picture != null">picture,</if>
<if test="idCode != null">id_code,</if>
<if test="versionId != null">version_id,</if>
<if test="introduce != null">introduce,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
@ -96,8 +75,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="modelName != null">#{modelName},</if>
<if test="model != null">#{model},</if>
<if test="picture != null">#{picture},</if>
<if test="idCode != null">#{idCode},</if>
<if test="versionId != null">#{versionId},</if>
<if test="introduce != null">#{introduce},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
@ -115,8 +92,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="modelName != null">model_name = #{modelName},</if>
<if test="model != null">model = #{model},</if>
<if test="picture != null">picture = #{picture},</if>
<if test="idCode != null">id_code = #{idCode},</if>
<if test="versionId != null">version_id = #{versionId},</if>
<if test="introduce != null">introduce = #{introduce},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>

View File

@ -14,7 +14,7 @@ import java.util.List;
* @author 邱贞招
* @date 2024-02-21
*/
public interface ISmModelService
public interface ModelService
{
/**
* 查询型号列表
@ -77,9 +77,9 @@ public interface ISmModelService
int logicDelete(List<Long> modelIds);
/**
* 根据物联网的型号查询数据
* 根据型号查询数据
*/
SmModelVo selectByIotModel(String model);
SmModelVo selectByModel(String model);
/**
* 创建初始型号

View File

@ -3,15 +3,16 @@ package com.ruoyi.ss.model.service;
import com.ruoyi.common.core.domain.ValidateResult;
import com.ruoyi.ss.model.domain.SmModelBO;
import java.util.List;
/**
* 2024/4/22
*/
public interface ModelValidator {
// 插入前校验
ValidateResult preInsert(SmModelBO bo);
// 更新前校验
ValidateResult preUpdate(SmModelBO bo);
// 判断型号是否重复
boolean isRepeatModel(Long modelId, String model);
// 判断型号标签是否合法
boolean hasTags(List<String> tags);
}

View File

@ -3,6 +3,7 @@ package com.ruoyi.ss.model.service.impl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.iot.domain.IotDeviceInfo;
import com.ruoyi.ss.device.domain.vo.SmDeviceVO;
import com.ruoyi.ss.device.service.ISmDeviceService;
@ -11,10 +12,10 @@ import com.ruoyi.ss.model.domain.SmModelBO;
import com.ruoyi.ss.model.domain.SmModelQuery;
import com.ruoyi.ss.model.domain.SmModelVo;
import com.ruoyi.ss.model.mapper.SmModelMapper;
import com.ruoyi.ss.model.service.ISmModelService;
import com.ruoyi.ss.model.service.ModelService;
import com.ruoyi.ss.model.service.ModelValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.Collections;
import java.util.List;
@ -28,14 +29,17 @@ import java.util.stream.Collectors;
* @date 2024-02-21
*/
@Service
public class SmModelServiceImpl implements ISmModelService
public class ModelServiceImpl implements ModelService
{
@Autowired
private SmModelMapper smModelMapper;
private SmModelMapper modelMapper;
@Autowired
private ISmDeviceService deviceService;
@Autowired
private ModelValidator modelValidator;
/**
* 查询型号列表
*
@ -45,7 +49,7 @@ public class SmModelServiceImpl implements ISmModelService
@Override
public SmModelVo selectSmModelByModelId(Long modelId)
{
return smModelMapper.selectSmModelByModelId(modelId);
return modelMapper.selectSmModelByModelId(modelId);
}
/**
@ -57,37 +61,41 @@ public class SmModelServiceImpl implements ISmModelService
@Override
public List<SmModelVo> selectSmModelList(SmModelQuery smModel)
{
return smModelMapper.selectSmModelList(smModel);
return modelMapper.selectSmModelList(smModel);
}
/**
* 新增型号列表
*
* @param smModel 型号列表
* @param data 型号列表
* @return 结果
*/
@Override
public int insertSmModel(SmModelBO smModel)
{
smModel.setCreateTime(DateUtils.getNowDate());
return smModelMapper.insertSmModel(smModel);
public int insertSmModel(SmModelBO data) {
ServiceUtil.assertion(data == null, "参数不能为空");
ServiceUtil.assertion(CollectionUtils.isEmptyElement(data.getTags()) && !modelValidator.hasTags(data.getTags()), "非法的标签");
ServiceUtil.assertion(modelValidator.isRepeatModel(data.getModelId(), data.getModel()), "型号重复");
data.setCreateTime(DateUtils.getNowDate());
return modelMapper.insertSmModel(data);
}
/**
* 修改型号列表
* 修改型号
*
* @param smModel 型号列表
* @param data 型号
* @return 结果
*/
@Override
public int updateSmModel(SmModelBO smModel)
{
smModel.setUpdateTime(DateUtils.getNowDate());
return smModelMapper.updateSmModel(smModel);
public int updateSmModel(SmModelBO data) {
ServiceUtil.assertion(data == null, "参数不能为空");
ServiceUtil.assertion(CollectionUtils.isEmptyElement(data.getTags()) && !modelValidator.hasTags(data.getTags()), "非法的标签");
ServiceUtil.assertion(modelValidator.isRepeatModel(data.getModelId(), data.getModel()), "型号重复");
data.setUpdateTime(DateUtils.getNowDate());
return modelMapper.updateSmModel(data);
}
/**
* 批量删除型号列表
* 批量删除型号
*
* @param modelIds 需要删除的型号列表主键
* @return 结果
@ -95,7 +103,7 @@ public class SmModelServiceImpl implements ISmModelService
@Override
public int deleteSmModelByModelIds(Long[] modelIds)
{
return smModelMapper.deleteSmModelByModelIds(modelIds);
return modelMapper.deleteSmModelByModelIds(modelIds);
}
/**
@ -107,28 +115,28 @@ public class SmModelServiceImpl implements ISmModelService
@Override
public int deleteSmModelByModelId(Long modelId)
{
return smModelMapper.deleteSmModelByModelId(modelId);
return modelMapper.deleteSmModelByModelId(modelId);
}
@Override
public Integer selectCount(SmModelQuery dto) {
return smModelMapper.selectCount(dto);
return modelMapper.selectCount(dto);
}
@Override
public int logicDelete(List<Long> modelIds) {
this.validatePreLogicDelete(modelIds);
return smModelMapper.logicDeleteByIds(modelIds);
return modelMapper.logicDeleteByIds(modelIds);
}
@Override
public SmModelVo selectByIotModel(String model) {
public SmModelVo selectByModel(String model) {
if (!StringUtils.hasText(model)) {
return null;
}
SmModelQuery query = new SmModelQuery();
query.setModel(model);
List<SmModelVo> list = smModelMapper.selectSmModelList(query);
List<SmModelVo> list = modelMapper.selectSmModelList(query);
if (CollectionUtils.isEmpty(list)) {
return null;
}
@ -143,7 +151,7 @@ public class SmModelServiceImpl implements ISmModelService
SmModel data = new SmModel();
data.setModelName("未命名");
data.setModel(deviceInfo.getModel());
return smModelMapper.insertSmModel(data);
return modelMapper.insertSmModel(data);
}
/**
@ -174,7 +182,7 @@ public class SmModelServiceImpl implements ISmModelService
}
SmModelQuery dto = new SmModelQuery();
dto.setModelIds(modelIds);
List<SmModelVo> list = smModelMapper.selectSmModelList(dto);
List<SmModelVo> list = modelMapper.selectSmModelList(dto);
if (CollectionUtils.isEmpty(list)) {
return Collections.emptyMap();
}

View File

@ -3,12 +3,17 @@ package com.ruoyi.ss.model.service.impl;
import com.ruoyi.common.core.domain.BaseValidator;
import com.ruoyi.common.core.domain.ValidateResult;
import com.ruoyi.ss.model.domain.SmModelBO;
import com.ruoyi.ss.model.domain.SmModelVo;
import com.ruoyi.ss.model.domain.enums.ModelTag;
import com.ruoyi.ss.model.service.ModelService;
import com.ruoyi.ss.model.service.ModelValidator;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Objects;
/**
* 2024/4/22
@ -16,37 +21,23 @@ import java.util.List;
@Service
public class ModelValidatorImpl extends BaseValidator implements ModelValidator {
@Autowired
private ModelService modelService;
@Override
public ValidateResult preInsert(SmModelBO bo) {
if (bo == null) {
return error("参数不能为空");
public boolean isRepeatModel(Long modelId, String model) {
if (StringUtils.isBlank(model)) {
return false;
}
if (!this.hasTags(bo.getTags())) {
return error("非法的标签");
}
return success();
}
@Override
public ValidateResult preUpdate(SmModelBO bo) {
if (bo == null) {
return error("参数不能为空");
}
if (!CollectionUtils.isEmpty(bo.getTags()) && this.hasTags(bo.getTags())) {
return error("非法的标签");
}
return success();
SmModelVo repeat = modelService.selectByModel(model);
return repeat != null && !Objects.equals(repeat.getModelId(), modelId);
}
/**
* 判断标签是否合法
*/
private boolean hasTags(List<String> tags) {
@Override
public boolean hasTags(List<String> tags) {
if (!CollectionUtils.isEmpty(tags)) {
return ModelTag.contains(tags);
}

View File

@ -62,7 +62,7 @@ public class UserAssemblerImpl implements UserAssembler {
SmDeviceQuery query = new SmDeviceQuery();
query.setUserIds(list.stream().map(SmUserVo::getUserId).collect(Collectors.toList()));
query.setGroupBy(DeviceGroupBy.user_id.name());
query.setGroupByTable(DeviceGroupByTable.ss.name());
query.setGroupByTable(DeviceGroupByTable.su.name());
Map<Long, Integer> map = deviceService.selectCommonCountMap(query, SmDeviceCountVO::getUserId);
for (SmUserVo user : list) {

View File

@ -87,7 +87,7 @@ public class AppDeviceController extends BaseController {
@ApiOperation("获取设备详细信息")
@GetMapping(value = "/{deviceId}")
public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId) {
ServiceUtil.assertion(!deviceValidator.isBelong(deviceId, getUserId()), "这不是您的设备");
// ServiceUtil.assertion(!deviceValidator.isBelong(deviceId, getUserId()), "这不是您的设备");
SmDeviceVO device = smDeviceService.selectSmDeviceByDeviceId(deviceId);
List<SmDeviceVO> list = Collections.singletonList(device);
deviceAssembler.assembleOrderCountInfo(list); // 订单统计信息

View File

@ -107,7 +107,6 @@ public class AppStoreController extends BaseController {
return AjaxResult.success(storeService.changeSort(list));
}
@MchRequired
@ApiOperation("获取当前用户店铺列表及其数量")
@GetMapping("/listCount")
@JsonView(StoreView.ListCount.class)

View File

@ -91,7 +91,7 @@ public class AppTransactionBillController extends BaseController
/**
* 查询收支列表
*/
@MchRequired
// @MchRequired
@ApiOperation("查询本人收支列表")
@GetMapping("/list")
@JsonView(JsonViewProfile.AppMch.class)
@ -114,7 +114,7 @@ public class AppTransactionBillController extends BaseController
return AjaxResult.success(bill);
}
@MchRequired
// @MchRequired
@ApiOperation("获取商户统计信息")
@JsonView(JsonViewProfile.AppMch.class)
@GetMapping("/landlordCount")
@ -175,7 +175,7 @@ public class AppTransactionBillController extends BaseController
return AjaxResult.success(smTransactionBillService.cancelRecharge(billNo, TransactionBillStatus.CANCELED));
}
@MchRequired
// @MchRequired
@ApiOperation("提现申请")
@PostMapping("/withdraw")
public AjaxResult withdraw(@RequestBody @Validated({ValidGroup.Withdraw.class}) TransactionBillBO data) {
@ -189,7 +189,7 @@ public class AppTransactionBillController extends BaseController
return AjaxResult.success(smTransactionBillService.selectDeviceRechargeFailList(getUserId()));
}
@MchRequired
// @MchRequired
@ApiOperation("获取设备充值列表")
@GetMapping("/rechargeListByDevice")
@JsonView(JsonViewProfile.AppMch.class)

View File

@ -25,8 +25,7 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ss.model.domain.SmModel;
import com.ruoyi.ss.model.service.ISmModelService;
import com.ruoyi.ss.model.service.ModelService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
@ -41,7 +40,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
public class SmModelController extends BaseController
{
@Autowired
private ISmModelService smModelService;
private ModelService smModelService;
@Autowired
private ModelValidator modelValidator;
@ -89,7 +88,6 @@ public class SmModelController extends BaseController
public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) SmModelBO smModel)
{
smModel = smModel.filterInsert();
ServiceUtil.assertion(modelValidator.preInsert(smModel));
return toAjax(smModelService.insertSmModel(smModel));
}
@ -102,7 +100,6 @@ public class SmModelController extends BaseController
public AjaxResult edit(@RequestBody @Validated(ValidGroup.Update.class) SmModelBO smModel)
{
smModel = smModel.filterUpdate();
ServiceUtil.assertion(modelValidator.preUpdate(smModel));
return toAjax(smModelService.updateSmModel(smModel));
}

View File

@ -1,5 +1,5 @@
# debug模式部分权限校验不生效
debug: false
debug: true
# 项目相关配置
ruoyi:

View File

@ -4,7 +4,7 @@ debug: false
# 项目相关配置
ruoyi:
# 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath
profile: /www/wwwroot/smart-swith/upload
profile: /home/www/projects/smart-switch/upload
wx:
# 微信小程序appId
@ -22,7 +22,7 @@ wx:
# 通知回调地址
notifyUrl: https://kg.chuantewulian.cn/test-api/app/pay/notify/wx # 测试环境
# 密钥所在位置
privateKeyPath: /www/wwwroot/smart-switch/wxpay/apiclient_key.pem
privateKeyPath: /home/www/projects/smart-switch/wxpay/apiclient_key.pem
# 证书序列号
merchantSerialNumber: 66910F800A60768020F07D39A56AE701574A16AE