Commit 12b51259 by YG8429

人工修改密码,小程序统计时长接口

parent a927ce9e
...@@ -99,8 +99,8 @@ public class DeviceController extends BaseController ...@@ -99,8 +99,8 @@ public class DeviceController extends BaseController
@PostMapping(value = "/updateDevicePassword") @PostMapping(value = "/updateDevicePassword")
public AjaxResult updateDevicePassword(@RequestBody Device device) public AjaxResult updateDevicePassword(@RequestBody Device device)
{ {
device.setDevPsw(device.getNewDevPsw()); AjaxResult ajaxResult = deviceService.updateRoomPassword(device);
return toAjax(deviceService.updateDevice(device)); return ajaxResult;
} }
/** /**
......
package share.web.controller.system; package share.web.controller.system;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -13,6 +14,7 @@ import share.system.domain.vo.DurationLogVo; ...@@ -13,6 +14,7 @@ import share.system.domain.vo.DurationLogVo;
import share.system.domain.vo.FrontTokenComponent; import share.system.domain.vo.FrontTokenComponent;
import share.system.service.DurationLogService; import share.system.service.DurationLogService;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
/** /**
...@@ -47,12 +49,11 @@ public class DurationLogController extends BaseController { ...@@ -47,12 +49,11 @@ public class DurationLogController extends BaseController {
return success(list); return success(list);
} }
@GetMapping("/queryDurationType") @GetMapping("/sumVariableDuration")
public AjaxResult queryDurationType(DurationLogVo durationLog) { public AjaxResult sumVariableDuration(DurationLogVo durationLog) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry(); SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
durationLog.setConsumerId(user.getId()); durationLog.setConsumerId(user.getId());
durationLog.setDurationType(DurationTypeEnum.SHARE.getCode()); BigDecimal sumVariableDuration = durationLogService.sumVariableDuration(durationLog);
List<DurationLogVo> list = durationLogService.selectDurationTypeList(durationLog); return success(sumVariableDuration);
return success(list);
} }
} }
package share.system.service; package share.system.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import share.common.core.domain.AjaxResult;
import share.common.core.page.TableDataInfo; import share.common.core.page.TableDataInfo;
import share.system.domain.Device; import share.system.domain.Device;
import share.system.domain.DeviceDto; import share.system.domain.DeviceDto;
...@@ -87,4 +88,6 @@ public interface DeviceService extends IService<Device> ...@@ -87,4 +88,6 @@ public interface DeviceService extends IService<Device>
TableDataInfo devicePage(DeviceDto device); TableDataInfo devicePage(DeviceDto device);
boolean updateDeviceDoorLockPassword(Integer validTime, Long storeId); boolean updateDeviceDoorLockPassword(Integer validTime, Long storeId);
AjaxResult updateRoomPassword(Device device);
} }
...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.DurationLog; import share.system.domain.DurationLog;
import share.system.domain.vo.DurationLogVo; import share.system.domain.vo.DurationLogVo;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
/** /**
...@@ -62,4 +63,6 @@ public interface DurationLogService extends IService<DurationLog> { ...@@ -62,4 +63,6 @@ public interface DurationLogService extends IService<DurationLog> {
public int deleteDurationLogById(Long id); public int deleteDurationLogById(Long id);
List<DurationLogVo> selectDurationTypeList(DurationLogVo durationLog); List<DurationLogVo> selectDurationTypeList(DurationLogVo durationLog);
BigDecimal sumVariableDuration(DurationLogVo durationLog);
} }
...@@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory; ...@@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import share.common.core.domain.AjaxResult;
import share.common.core.page.PageDomain; import share.common.core.page.PageDomain;
import share.common.core.page.TableDataInfo; import share.common.core.page.TableDataInfo;
import share.common.core.page.TableSupport; import share.common.core.page.TableSupport;
...@@ -259,6 +260,31 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme ...@@ -259,6 +260,31 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
} }
@Override @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) { public List<Device> notRoomIdList(Device device) {
SRoom room = roomMapper.selectSRoomById(device.getRoomId()); SRoom room = roomMapper.selectSRoomById(device.getRoomId());
if (room != null) { if (room != null) {
......
...@@ -11,6 +11,7 @@ import share.system.domain.vo.DurationLogVo; ...@@ -11,6 +11,7 @@ import share.system.domain.vo.DurationLogVo;
import share.system.mapper.DurationLogMapper; import share.system.mapper.DurationLogMapper;
import share.system.service.DurationLogService; import share.system.service.DurationLogService;
import java.math.BigDecimal;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
...@@ -99,4 +100,14 @@ public class DurationLogServiceImpl extends ServiceImpl<DurationLogMapper, Durat ...@@ -99,4 +100,14 @@ public class DurationLogServiceImpl extends ServiceImpl<DurationLogMapper, Durat
return durationLogMapper.selectDurationLogList(durationLog); 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