| | |
| | | package com.ruoyi.iot.controller; |
| | | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.file.FileUploadUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.iot.domain.Device; |
| | | import com.ruoyi.iot.domain.DeviceOrder; |
| | | import com.ruoyi.iot.domain.DeviceOrderTime; |
| | | import com.ruoyi.iot.service.IDeviceOrderService; |
| | | import com.ruoyi.iot.service.IDeviceOrderTimeService; |
| | | import com.ruoyi.iot.service.IDeviceService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.security.core.parameters.P; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.IOException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @ApiOperation(value = "获取未派单/已派单/已接单/已完成的安装单/维修单数量") |
| | | public AjaxResult selectDeviceOrderCount(DeviceOrder deviceOrder) throws Exception { |
| | | if (deviceOrder != null) { |
| | | return iDeviceOrderService.selectDeviceOrderCountByUndeliveredorders(deviceOrder); |
| | | return iDeviceOrderService.selectDeviceOrderCountByUndeliveredOrders(deviceOrder); |
| | | } else { |
| | | return AjaxResult.error("未查询到有关信息"); |
| | | } |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @ApiOperation("添加安装单") |
| | | @ApiOperation("添加安装单/维修单") |
| | | @PreAuthorize("@ss.hasPermi('iot:device:add')") |
| | | @Log(title = "添加安装单信息", businessType = BusinessType.INSERT) |
| | | @Log(title = "添加安装单/维修单信息", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody DeviceOrder deviceOrder) throws Exception { |
| | | return iDeviceOrderService.insertDeviceOrder(deviceOrder); |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('iot:device:remove')") |
| | | @Log(title = "删除设备订单信息", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{deviceId}") |
| | | @ApiOperation("删除订单信息") |
| | | public AjaxResult remove(@PathVariable("deviceId") Integer deviceId) throws Exception { |
| | | return iDeviceOrderService.deleteDeviceOrderById(deviceId); |
| | | @DeleteMapping("/{id}/{deviceId}") |
| | | @ApiOperation("删除设备订单信息") |
| | | public AjaxResult remove(@PathVariable("id") Long id, @PathVariable("deviceId") Long deviceId) throws Exception { |
| | | return iDeviceOrderService.deleteDeviceOrderById(id, deviceId); |
| | | } |
| | | |
| | | /** |
| | | * 安装单/维修单图片上传 |
| | | * 安装单图片上传 |
| | | * |
| | | * @param file |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | |
| | | @Log(title = "安装单/维修单图片上传", businessType = BusinessType.INSERT) |
| | | @PostMapping("/profile/avatar") |
| | | @ApiOperation("安装单/维修单图片上传") |
| | | public AjaxResult imgurl(@RequestParam("avatarfile") MultipartFile file) throws Exception { |
| | | @Log(title = "安装单图片上传", businessType = BusinessType.INSERT) |
| | | @PostMapping("/Install/profile/avatar") |
| | | @ApiOperation("安装单图片上传") |
| | | public AjaxResult deviceOrderinstallImgUrl(@RequestParam("avatarfile") MultipartFile file) throws Exception { |
| | | // 判断头像文件不为空 |
| | | if (!file.isEmpty()) { |
| | | // 通过Security获取到登录的用户信息 |
| | | LoginUser loginUser = getLoginUser(); |
| | | String avatar = FileUploadUtils.upload(RuoYiConfig.getDeviceOrderPath(), file); |
| | | String avatar = FileUploadUtils.upload(RuoYiConfig.getDeviceOrderInstallPath(), file); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("imgUrl", avatar); |
| | | return ajax; |
| | | } |
| | | return AjaxResult.error("图片上传失败"); |
| | | } |
| | | |
| | | /** |
| | | * 维修单图片上传 |
| | | * |
| | | * @param file |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Log(title = "维修单图片上传", businessType = BusinessType.INSERT) |
| | | @PostMapping("/Repair/profile/avatar") |
| | | @ApiOperation("维修单图片上传") |
| | | public AjaxResult deviceOrderRepairImgUrl(@RequestParam("avatarfile") MultipartFile file) throws Exception { |
| | | // 判断头像文件不为空 |
| | | if (!file.isEmpty()) { |
| | | // 通过Security获取到登录的用户信息 |
| | | LoginUser loginUser = getLoginUser(); |
| | | String avatar = FileUploadUtils.upload(RuoYiConfig.getDeviceOrderRepairPath(), file); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("imgUrl", avatar); |
| | | return ajax; |