| | |
| | | package com.ruoyi.iot.service.impl; |
| | | |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.iot.domain.DeviceOrderTime; |
| | | import com.ruoyi.iot.mapper.DeviceOrderTimeMapper; |
| | | import com.ruoyi.iot.service.IDeviceOrderTimeService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author wmz |
| | |
| | | * @createTime 2023/11/30 14:52 |
| | | */ |
| | | @Service |
| | | public class DeviceOrderTimeServiceImpl implements IDeviceOrderTimeService { |
| | | public class DeviceOrderTimeServiceImpl extends BaseController implements IDeviceOrderTimeService { |
| | | |
| | | @Resource |
| | | private DeviceOrderTimeMapper deviceOrderTimeMapper; |
| | | |
| | | /** |
| | | * 根据登录的联营商查询接单超时的时间间隔 |
| | | * 根据登录的联营商查询接单,完成的超时的时间间隔 |
| | | * |
| | | * @param deviceOrderTime |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public List<DeviceOrderTime> selectReceiveTimeoutById(DeviceOrderTime deviceOrderTime) throws Exception { |
| | | return deviceOrderTimeMapper.selectReceiveTimeoutById(deviceOrderTime); |
| | | } |
| | | |
| | | /** |
| | | * 根据登录的联营商查询接单完成的时间间隔 |
| | | * |
| | | * @param deviceOrderTime |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public List<DeviceOrderTime> selectFinishTimeoutById(DeviceOrderTime deviceOrderTime) throws Exception { |
| | | return deviceOrderTimeMapper.selectFinishTimeoutById(deviceOrderTime); |
| | | public AjaxResult selectDeviceOrderTimeoutById(DeviceOrderTime deviceOrderTime) throws Exception { |
| | | DeviceOrderTime userDeviceOrderA = deviceOrderTimeMapper.selectDeviceOrderTimeByUserId(deviceOrderTime.getUserId(), deviceOrderTime.getOrderType()); |
| | | if (userDeviceOrderA != null) { |
| | | DeviceOrderTime userDeviceOrderB = deviceOrderTimeMapper.selectDeviceOrderTimeoutById(deviceOrderTime); |
| | | System.out.println(userDeviceOrderB); |
| | | return AjaxResult.success("查询成功", userDeviceOrderB); |
| | | } else { |
| | | deviceOrderTime.setReceiveTimeout(0); |
| | | deviceOrderTime.setFinishTimeout(0); |
| | | int row = deviceOrderTimeMapper.insertDeviceOrderTimeout(deviceOrderTime); |
| | | if (row > 0) { |
| | | DeviceOrderTime userDeviceOrderC = deviceOrderTimeMapper.selectDeviceOrderTimeoutById(deviceOrderTime); |
| | | return AjaxResult.success("查询成功", userDeviceOrderC); |
| | | } else { |
| | | return AjaxResult.error("添加数据失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | return deviceOrderTimeMapper.selectDeviceOrderTimeByUserId(id, orderType); |
| | | } |
| | | |
| | | public static void main(String[] args) throws Exception{ |
| | | IDeviceOrderTimeService iDeviceOrderTimeService = new DeviceOrderTimeServiceImpl(); |
| | | DeviceOrderTime deviceOrderTime = iDeviceOrderTimeService.selectDeviceOrderTimeByUserId(14, 1); |
| | | System.out.println(deviceOrderTime); |
| | | } |
| | | /** |
| | | * 初次登录的用户如果表中没有数据就添加数据 |
| | | * |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public int updateDeviceOrderTimeoutById(DeviceOrderTime orderTime) throws Exception { |
| | | return deviceOrderTimeMapper.updateDeviceOrderTimeoutById(orderTime); |
| | | public AjaxResult updateDeviceOrderTimeoutById(DeviceOrderTime orderTime) throws Exception { |
| | | DeviceOrderTime userDeviceOrder = deviceOrderTimeMapper.selectDeviceOrderTimeByUserId(orderTime.getUserId(), orderTime.getOrderType()); |
| | | if (userDeviceOrder != null) { |
| | | return toAjax(deviceOrderTimeMapper.updateDeviceOrderTimeoutById(orderTime)); |
| | | } else { |
| | | orderTime.setReceiveTimeout(0); |
| | | orderTime.setFinishTimeout(0); |
| | | int rowsB = deviceOrderTimeMapper.insertDeviceOrderTimeout(orderTime); |
| | | if (rowsB > 0) { |
| | | return toAjax(deviceOrderTimeMapper.updateDeviceOrderTimeoutById(orderTime)); |
| | | } else { |
| | | return AjaxResult.error("添加数据失败"); |
| | | } |
| | | } |
| | | } |
| | | } |