食堂-双屏机:更新设备在线状态
This commit is contained in:
		
							parent
							
								
									6998d34ae8
								
							
						
					
					
						commit
						93aa13a9fa
					
				| 
						 | 
				
			
			@ -2,6 +2,10 @@ package com.bonus.canteen.core.device.controller;
 | 
			
		|||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import javax.servlet.http.HttpServletResponse;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.util.ObjectUtil;
 | 
			
		||||
import com.bonus.canteen.core.device.domain.DeviceSearchDTO;
 | 
			
		||||
import com.bonus.common.core.exception.ServiceException;
 | 
			
		||||
import com.bonus.common.log.enums.OperaType;
 | 
			
		||||
//import com.bonus.canteen.core.device.common.annotation.PreventRepeatSubmit;
 | 
			
		||||
import io.swagger.annotations.Api;
 | 
			
		||||
| 
						 | 
				
			
			@ -87,8 +91,6 @@ public class DeviceInfoController extends BaseController {
 | 
			
		|||
     * 修改设备资料
 | 
			
		||||
     */
 | 
			
		||||
    @ApiOperation(value = "修改设备资料")
 | 
			
		||||
    //@PreventRepeatSubmit
 | 
			
		||||
    //@RequiresPermissions("device:info:edit")
 | 
			
		||||
    @SysLog(title = "设备资料", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改设备资料")
 | 
			
		||||
    @PostMapping("/edit")
 | 
			
		||||
    public AjaxResult edit(@RequestBody DeviceInfo deviceInfo) {
 | 
			
		||||
| 
						 | 
				
			
			@ -103,11 +105,20 @@ public class DeviceInfoController extends BaseController {
 | 
			
		|||
     * 删除设备资料
 | 
			
		||||
     */
 | 
			
		||||
    @ApiOperation(value = "删除设备资料")
 | 
			
		||||
    //@PreventRepeatSubmit
 | 
			
		||||
    //@RequiresPermissions("device:info:remove")
 | 
			
		||||
    @SysLog(title = "设备资料", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除设备资料")
 | 
			
		||||
	@PostMapping("/del/{deviceIds}")
 | 
			
		||||
    public AjaxResult remove(@PathVariable Long[] deviceIds) {
 | 
			
		||||
        return toAjax(deviceInfoService.deleteDeviceInfoByDeviceIds(deviceIds));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "更新设备在线状态")
 | 
			
		||||
    @PostMapping({"/updateTimeBySn"})
 | 
			
		||||
    public AjaxResult updateTimeBySn(@RequestBody DeviceSearchDTO dto) {
 | 
			
		||||
        if (ObjectUtil.isEmpty(dto.getDeviceSn())) {
 | 
			
		||||
            throw new ServiceException("设备sn不能为空");
 | 
			
		||||
        }
 | 
			
		||||
        this.deviceInfoService.updateTimeBySn(dto.getDeviceSn());
 | 
			
		||||
        return AjaxResult.success();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,10 @@
 | 
			
		|||
package com.bonus.canteen.core.device.domain;
 | 
			
		||||
 | 
			
		||||
import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
@Data
 | 
			
		||||
public class DeviceSearchDTO {
 | 
			
		||||
    @ApiModelProperty("设备sn码")
 | 
			
		||||
    private String deviceSn;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -136,4 +136,12 @@ public interface DeviceInfoMapper {
 | 
			
		|||
     * @param deviceIds 需要删除的数据主键集合
 | 
			
		||||
     */
 | 
			
		||||
    void deleteDeviceRecipeBinding(@Param("deviceIds") Long[] deviceIds);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 更新设备在线状态
 | 
			
		||||
     *
 | 
			
		||||
     * @param sn 设备序列号
 | 
			
		||||
     * @return 结果
 | 
			
		||||
     */
 | 
			
		||||
    int updateTimeBySn(String sn);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -57,4 +57,10 @@ public interface IDeviceInfoService {
 | 
			
		|||
     * @return 结果
 | 
			
		||||
     */
 | 
			
		||||
    public int deleteDeviceInfoByDeviceId(Long deviceId);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据设备sn码更新设备最后使用时间
 | 
			
		||||
     * @param deviceSn 设备sn码
 | 
			
		||||
     */
 | 
			
		||||
    void updateTimeBySn(String deviceSn);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -152,4 +152,18 @@ public class DeviceInfoServiceImpl implements IDeviceInfoService {
 | 
			
		|||
    public int deleteDeviceInfoByDeviceId(Long deviceId) {
 | 
			
		||||
        return deviceInfoMapper.deleteDeviceInfoByDeviceId(deviceId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据sn更新时间
 | 
			
		||||
     *
 | 
			
		||||
     * @param sn 设备sn码
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void updateTimeBySn(String sn) {
 | 
			
		||||
        int code = deviceInfoMapper.updateTimeBySn(sn);
 | 
			
		||||
        if (code == 0) {
 | 
			
		||||
            throw new RuntimeException("更新时间失败");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -279,6 +279,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
        </trim>
 | 
			
		||||
        where device_id = #{deviceId}
 | 
			
		||||
    </update>
 | 
			
		||||
    <update id="updateTimeBySn">
 | 
			
		||||
        update device_info
 | 
			
		||||
        set last_update_time = unix_timestamp()
 | 
			
		||||
        where device_sn = #{sn}
 | 
			
		||||
    </update>
 | 
			
		||||
 | 
			
		||||
    <delete id="deleteDeviceInfoByDeviceId" parameterType="Long">
 | 
			
		||||
        delete from device_info where device_id = #{deviceId}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue