| | |
| | | package com.ruoyi.iot.controller; |
| | | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | 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.file.FileUploadUtils; |
| | | import com.ruoyi.iot.domain.DeviceOrder; |
| | | import com.ruoyi.iot.domain.DeviceOrderTime; |
| | | import com.ruoyi.iot.service.IDeviceOrderService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.iot.service.IDeviceOrderTimeService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | 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.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.thymeleaf.util.ArrayUtils; |
| | | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | |
| | | * @author wmz |
| | | * @version v1.0 |
| | | * @ClassName DeviceOrderController |
| | | * @description 设备安装controller |
| | | * @description 设备安装单/维修单controller |
| | | * @createTime 2023/11/13 0:27 |
| | | */ |
| | | @Api(tags = "设备安装信息") |
| | |
| | | @RequestMapping("/iot/deviceOrder") |
| | | public class DeviceOrderController extends BaseController { |
| | | |
| | | private static final Logger log = LoggerFactory.getLogger(DeviceOrderController.class); |
| | | |
| | | @Resource |
| | | private IDeviceOrderService iDeviceOrderService; |
| | | @Resource |
| | | private ISysUserService userService; |
| | | |
| | | @Autowired |
| | | private IDeviceOrderTimeService deviceOrderTimeService; |
| | | |
| | | /** |
| | | * 查询全部设备订单信息 |
| | | * 查询全部设备安装单订单信息 |
| | | * |
| | | * @param deviceOrder |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | |
| | | @ApiOperation(value = "获取设备订单分页列表") |
| | | public TableDataInfo list(DeviceOrder deviceOrder) throws Exception { |
| | | startPage(); |
| | | if (deviceOrder.getState() == -1) { |
| | | List<DeviceOrder> list1 = iDeviceOrderService.selectDeviceOrderAll(); |
| | | return getDataTable(list1); |
| | | } |
| | | List<DeviceOrder> list = iDeviceOrderService.selectDeviceOrderList(deviceOrder); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | /** |
| | | * 根据登录的联营商查询设备订单超时的时间间隔 |
| | | * |
| | | * @param deviceOrderTime |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @PreAuthorize("@ss.hasAnyPermi('iot:deviceOrder:list')") |
| | | @GetMapping("/selecttimeout") |
| | | @ApiOperation(value = "根据登录的联营商查询设备订单超时的时间间隔") |
| | | public AjaxResult selectTimeout(DeviceOrderTime deviceOrderTime) throws Exception { |
| | | return deviceOrderTimeService.selectDeviceOrderTimeoutById(deviceOrderTime); |
| | | } |
| | | |
| | | /** |
| | | * 根据登录的联营商修改设备订单超时的时间间隔 |
| | | * |
| | | * @param deviceOrderTime |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @PreAuthorize("@ss.hasAnyPermi('iot:deviceOrder:list')") |
| | | @Log(title = "联营商登录后修改设备订单超时的时间间隔", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/updatetimeout") |
| | | @ApiOperation(value = "根据登录的联营商修改设备订单超时的时间间隔") |
| | | public AjaxResult assignDeviceOrderTimeout(DeviceOrderTime deviceOrderTime) throws Exception { |
| | | return deviceOrderTimeService.updateDeviceOrderTimeoutById(deviceOrderTime); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 安装单/维修单完成后用户的评价 |
| | | * |
| | | * @param deviceOrder |
| | | * @return |
| | | * @throws Exception 参数是安装单的id,用户的id,ordertype类型 |
| | | */ |
| | | @PreAuthorize("@ss.hasAnyPermi('iot:deviceOrder:list')") |
| | | @PostMapping("/editDeviceOrderScore") |
| | | @Log(title = "安装单/维修单完成后用户添加评价", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "安装单/维修单完成后用户的评价") |
| | | public AjaxResult updateDeviceOrderScoreAndComment(DeviceOrder deviceOrder) throws Exception { |
| | | return iDeviceOrderService.updateDeviceOrderScoreAndComment(deviceOrder); |
| | | } |
| | | |
| | | /** |
| | | * 查询未派单/已派单/已接单/已完成的安装单/维修单数维修单数量 |
| | | * |
| | | * @param deviceOrder |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @PreAuthorize("@ss.hasAnyPermi('iot:deviceOrder:list')") |
| | | @GetMapping("/get") |
| | | @ApiOperation(value = "获取未派单/已派单/已接单/已完成的安装单/维修单数量") |
| | | public AjaxResult selectDeviceOrderCount(DeviceOrder deviceOrder) throws Exception { |
| | | if (deviceOrder != null) { |
| | | 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 { |
| | | deviceOrder.setState(0); |
| | | return AjaxResult.success(iDeviceOrderService.insertDeviceOrder(deviceOrder)); |
| | | return iDeviceOrderService.insertDeviceOrder(deviceOrder); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Log(title = "修改设备订单信息", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody DeviceOrder deviceOrder) throws Exception { |
| | | return AjaxResult.success(iDeviceOrderService.updateDeviceOrder(deviceOrder)); |
| | | return iDeviceOrderService.updateDeviceOrder(deviceOrder); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('iot:device:list')") |
| | | @Log(title = "修改设备订单信息", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{deviceId}") |
| | | @ApiOperation("删除订单信息") |
| | | public AjaxResult remove(@PathVariable("deviceId") Integer deviceId) throws Exception { |
| | | return AjaxResult.success(iDeviceOrderService.deleteDeviceOrderById(deviceId)); |
| | | @PreAuthorize("@ss.hasPermi('iot:device:remove')") |
| | | @Log(title = "删除设备订单信息", businessType = BusinessType.DELETE) |
| | | @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("/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.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; |
| | | } |
| | | return AjaxResult.error("图片上传失败"); |
| | | } |
| | | } |
| | | |