Commit 4e571d9a by 吕明尚

Merge branch 'dev' into test

parents 25b8b35e 12b51259
......@@ -99,8 +99,8 @@ public class DeviceController extends BaseController
@PostMapping(value = "/updateDevicePassword")
public AjaxResult updateDevicePassword(@RequestBody Device device)
{
device.setDevPsw(device.getNewDevPsw());
return toAjax(deviceService.updateDevice(device));
AjaxResult ajaxResult = deviceService.updateRoomPassword(device);
return ajaxResult;
}
/**
......
package share.web.controller.system;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -13,6 +14,7 @@ import share.system.domain.vo.DurationLogVo;
import share.system.domain.vo.FrontTokenComponent;
import share.system.service.DurationLogService;
import java.math.BigDecimal;
import java.util.List;
/**
......@@ -47,12 +49,11 @@ public class DurationLogController extends BaseController {
return success(list);
}
@GetMapping("/queryDurationType")
public AjaxResult queryDurationType(DurationLogVo durationLog) {
@GetMapping("/sumVariableDuration")
public AjaxResult sumVariableDuration(DurationLogVo durationLog) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
durationLog.setConsumerId(user.getId());
durationLog.setDurationType(DurationTypeEnum.SHARE.getCode());
List<DurationLogVo> list = durationLogService.selectDurationTypeList(durationLog);
return success(list);
BigDecimal sumVariableDuration = durationLogService.sumVariableDuration(durationLog);
return success(sumVariableDuration);
}
}
package share.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import share.common.core.domain.AjaxResult;
import share.common.core.page.TableDataInfo;
import share.system.domain.Device;
import share.system.domain.DeviceDto;
......@@ -87,4 +88,6 @@ public interface DeviceService extends IService<Device>
TableDataInfo devicePage(DeviceDto device);
boolean updateDeviceDoorLockPassword(Integer validTime, Long storeId);
AjaxResult updateRoomPassword(Device device);
}
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.DurationLog;
import share.system.domain.vo.DurationLogVo;
import java.math.BigDecimal;
import java.util.List;
/**
......@@ -62,4 +63,6 @@ public interface DurationLogService extends IService<DurationLog> {
public int deleteDurationLogById(Long id);
List<DurationLogVo> selectDurationTypeList(DurationLogVo durationLog);
BigDecimal sumVariableDuration(DurationLogVo durationLog);
}
......@@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import share.common.core.domain.AjaxResult;
import share.common.core.page.PageDomain;
import share.common.core.page.TableDataInfo;
import share.common.core.page.TableSupport;
......@@ -259,6 +260,31 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
}
@Override
public AjaxResult updateRoomPassword(Device device) {
Integer validTime = 365;
Date now = DateUtil.date();
String startTime = DateUtil.formatDateTime(now);
String endTime = DateUtil.formatDateTime(DateUtil.offsetDay(now, validTime));
SRoom room = new SRoom();
room.setId(device.getRoomId());
room.setPassword(device.getNewDevPsw());
roomService.updateById(room);
// 设备密码修改记录
DevicePasswordLog log = new DevicePasswordLog();
log.setRoomId(device.getRoomId());
log.setPassword(device.getNewDevPsw());
log.setDevId(device.getDevId());
log.setStartTime(now);
log.setEndTime(DateUtil.offsetDay(now, validTime));
log.setCreateTime(now);
devicePasswordLogService.insertDevicePasswordLog(log);
deviceOpService.setDevicePassword(device.getRoomId(), device.getNewDevPsw(),
startTime, endTime, "13800000000", OpTypeEnum.OP_DEVICE_PASSWORD.getCode(),
DeviceOpSourceEnum.DEVICE_SOURCE_40.getCode());
return AjaxResult.success();
}
@Override
public List<Device> notRoomIdList(Device device) {
SRoom room = roomMapper.selectSRoomById(device.getRoomId());
if (room != null) {
......
......@@ -11,6 +11,7 @@ import share.system.domain.vo.DurationLogVo;
import share.system.mapper.DurationLogMapper;
import share.system.service.DurationLogService;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
......@@ -99,4 +100,14 @@ public class DurationLogServiceImpl extends ServiceImpl<DurationLogMapper, Durat
return durationLogMapper.selectDurationLogList(durationLog);
}
@Override
public BigDecimal sumVariableDuration(DurationLogVo durationLog) {
LambdaQueryWrapper<DurationLog> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(DurationLog::getConsumerId, durationLog.getConsumerId());
queryWrapper.eq(DurationLog::getDurationType, DurationTypeEnum.SHARE.getCode());
return durationLogMapper.selectList(queryWrapper)
.stream().map(DurationLog::getVariableDuration)
.reduce(BigDecimal.ZERO, BigDecimal::add);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment