| | |
| | | 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.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.IDeviceService; |
| | | 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.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author wmz |
| | | * @version v1.0 |
| | | * @ClassName DeviceOrderController |
| | | * @description 设备安装controller |
| | | * @description 设备安装单/维修单controller |
| | | * @createTime 2023/11/13 0:27 |
| | | */ |
| | | @Api(tags = "设备安装信息") |
| | |
| | | private IDeviceOrderService iDeviceOrderService; |
| | | |
| | | @Autowired |
| | | private IDeviceService deviceService; |
| | | |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | private IDeviceOrderTimeService deviceOrderTimeService; |
| | | |
| | | /** |
| | | * 查询全部设备安装单订单信息 |
| | | * |
| | | * @param deviceOrder |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 根据登录的联营商查询设备订单超时的时间间隔 |
| | | * |
| | | * @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("未查询到有关信息"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加安装设备订单信息 |
| | | * |
| | | * @param deviceOrder |
| | | * @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 { |
| | | //更新订单的初始化状态 |
| | | if ("未指派".equals(deviceOrder.getErectoName())) { |
| | | deviceOrder.setState(0); |
| | | } else { |
| | | deviceOrder.setState(1); |
| | | } |
| | | if ("2".equals(deviceOrder.getOrderType())) { |
| | | Device device = new Device(); |
| | | device.setDeviceId(deviceOrder.getDeviceId()); |
| | | device.setRepairFlag(1); |
| | | deviceService.updateDevice(device); |
| | | } |
| | | //更新订单的用户信息 |
| | | SysUser sysUser = getLoginUser().getUser(); |
| | | deviceOrder.setCreateUserId(sysUser.getUserId()); |
| | | //插入安装订单 |
| | | int rows = iDeviceOrderService.insertDeviceOrder(deviceOrder); |
| | | if (rows > 0) { |
| | | //更新当前设备状态信息--安装中 |
| | | Device device = new Device(); |
| | | device.setDeviceId(deviceOrder.getDeviceId()); |
| | | device.setStatus(5); |
| | | deviceService.updateDevice(device); |
| | | } |
| | | return toAjax(rows); |
| | | return iDeviceOrderService.insertDeviceOrder(deviceOrder); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Log(title = "修改设备订单信息", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody DeviceOrder deviceOrder) throws Exception { |
| | | if ("1".equals(deviceOrder.getOrderType()) && deviceOrder.getState() == 3) { |
| | | Device device = new Device(); |
| | | device.setDeviceId(deviceOrder.getDeviceId()); |
| | | device.setStatus(4); |
| | | deviceService.updateDevice(device); |
| | | } |
| | | if ("2".equals(deviceOrder.getOrderType()) && deviceOrder.getState() == 3) { |
| | | Device device = new Device(); |
| | | device.setDeviceId(deviceOrder.getDeviceId()); |
| | | device.setRepairFlag(0); |
| | | } |
| | | //获取修改订单的用户信息 |
| | | SysUser sysUser = getLoginUser().getUser(); |
| | | //拿到修改安装单的用户id |
| | | deviceOrder.setUpdateUserId(sysUser.getUserId()); |
| | | return toAjax(iDeviceOrderService.updateDeviceOrder(deviceOrder)); |
| | | return iDeviceOrderService.updateDeviceOrder(deviceOrder); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('iot:device:remove')") |
| | | @Log(title = "删除设备订单信息", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{deviceId}") |
| | | @ApiOperation("删除订单信息") |
| | | public AjaxResult remove(@PathVariable("deviceId") Integer deviceId) throws Exception { |
| | | //根据要删除安装单的id查询出安装单信息 |
| | | DeviceOrder deviceOrder = iDeviceOrderService.selectDeviceOrderById(deviceId); |
| | | SysUser user = getLoginUser().getUser(); |
| | | //如果根据查询出来的安装单对象不为空的话,并且状态等于未派单才可以删除 |
| | | if (deviceOrder != null && deviceOrder.getState() == 0 && user.getUserId() != 1) { |
| | | //未派单的安装单删除后设备的状态更新为-未激活 |
| | | Device device = new Device(); |
| | | device.setDeviceId(deviceOrder.getDeviceId()); |
| | | device.setStatus(1); |
| | | deviceService.updateDevice(device); |
| | | int i = iDeviceOrderService.deleteDeviceOrderById(deviceOrder.getId()); |
| | | return toAjax(i); |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | @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) |
| | | @Log(title = "安装单/维修单图片上传", businessType = BusinessType.INSERT) |
| | | @PostMapping("/profile/avatar") |
| | | @ApiOperation("安装单图片上传") |
| | | @ApiOperation("安装单/维修单图片上传") |
| | | public AjaxResult imgurl(@RequestParam("avatarfile") MultipartFile file) throws Exception { |
| | | // 判断头像文件不为空 |
| | | if (!file.isEmpty()) { |