| | |
| | | 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 javax.annotation.Resource; |
| | | import java.io.IOException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | private IDeviceService deviceService; |
| | | |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | private IDeviceOrderTimeService deviceOrderTimeService; |
| | | |
| | | /** |
| | | * 查询全部设备安装单订单信息 |
| | | * |
| | | * @param deviceOrder |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | |
| | | startPage(); |
| | | 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 { |
| | | DeviceOrderTime userDeviceOrder = deviceOrderTimeService.selectDeviceOrderTimeByUserId(deviceOrderTime.getUserId(), deviceOrderTime.getOrderType()); |
| | | if (userDeviceOrder != null) { |
| | | List<DeviceOrderTime> rowsA = deviceOrderTimeService.selectReceiveTimeoutById(deviceOrderTime); |
| | | List<DeviceOrderTime> rowsB = deviceOrderTimeService.selectFinishTimeoutById(deviceOrderTime); |
| | | AjaxResult ajax = new AjaxResult(); |
| | | ajax.put("receiveTimeout", rowsA); |
| | | ajax.put("finishTimeout", rowsB); |
| | | return AjaxResult.success("查询成功", ajax); |
| | | } else { |
| | | deviceOrderTime.setReceiveTimeout(0); |
| | | deviceOrderTime.setFinishTimeout(0); |
| | | int row = deviceOrderTimeService.insertDeviceOrderTimeout(deviceOrderTime); |
| | | if (row > 0) { |
| | | List<DeviceOrderTime> rowsA = deviceOrderTimeService.selectReceiveTimeoutById(deviceOrderTime); |
| | | List<DeviceOrderTime> rowsB = deviceOrderTimeService.selectFinishTimeoutById(deviceOrderTime); |
| | | AjaxResult ajax = new AjaxResult(); |
| | | ajax.put("receiveTimeout", rowsA); |
| | | ajax.put("finishTimeout", rowsB); |
| | | return AjaxResult.success("查询成功", ajax); |
| | | } else { |
| | | return AjaxResult.error("添加数据失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据登录的联营商修改设备订单超时的时间间隔 |
| | | * |
| | | * @param deviceOrderTime |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @PreAuthorize("@ss.hasAnyPermi('iot:deviceOrder:list')") |
| | | @Log(title = "修改设备订单信息", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/updatetimeout") |
| | | @ApiOperation(value = "根据登录的联营商修改设备订单超时的时间间隔") |
| | | public AjaxResult assignDeviceOrderTimeout(DeviceOrderTime deviceOrderTime) throws Exception { |
| | | DeviceOrderTime userDeviceOrder = deviceOrderTimeService.selectDeviceOrderTimeByUserId(deviceOrderTime.getUserId(), deviceOrderTime.getOrderType()); |
| | | if (userDeviceOrder != null) { |
| | | return toAjax(deviceOrderTimeService.updateDeviceOrderTimeoutById(deviceOrderTime)); |
| | | } else { |
| | | int rowsB = deviceOrderTimeService.insertDeviceOrderTimeout(deviceOrderTime); |
| | | if (rowsB > 0) { |
| | | return toAjax(deviceOrderTimeService.updateDeviceOrderTimeoutById(deviceOrderTime)); |
| | | } else { |
| | | return AjaxResult.error("添加数据失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询未派单/已派单/已接单/已完成的安装单/维修单数维修单数量 |
| | | * |
| | | * @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) { |
| | | //根据登录的用户来查询自己未派单的安装单/维修单数量 |
| | | int count = iDeviceOrderService.selectDeviceOrderCountByUndeliveredorders(deviceOrder); |
| | | //根据登录的用户来查询自己已派单的安装单/维修单数量 |
| | | int total = iDeviceOrderService.selectDeviceOrderCountByDispatchedorders(deviceOrder); |
| | | //根据登录的用户来查询自己已接单的安装单/维修单数量 |
| | | int number = iDeviceOrderService.selectDeviceOrderCountByReceivedorders(deviceOrder); |
| | | //根据登录的用户来查询自己已完成的安装单/维修单数量 |
| | | int amount = iDeviceOrderService.selectDeviceOrderCountByCompleted(deviceOrder); |
| | | AjaxResult ajax = new AjaxResult(); |
| | | //未派单的安装单/维修单的数量 |
| | | ajax.put("deviceOrderUndeliveredorders", count); |
| | | //已派单的安装单/维修单的数量 |
| | | ajax.put("deviceOrderDispatchedorders", total); |
| | | //已接单的安装单/维修单的数量 |
| | | ajax.put("deviceOrderReceivedorders", number); |
| | | //已完成的安装单/维修单的数量 |
| | | ajax.put("deviceOrderCompleted", amount); |
| | | return AjaxResult.success("查询成功", ajax); |
| | | } else { |
| | | return AjaxResult.error("未查询到有关信息"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | } else { |
| | | deviceOrder.setState(1); |
| | | } |
| | | //判断传过来的orderType的值是否为2-维修 |
| | | if ("2".equals(deviceOrder.getOrderType())) { |
| | | Device device = new Device(); |
| | | device.setDeviceId(deviceOrder.getDeviceId()); |
| | | device.setRepairFlag(1); |
| | | deviceService.updateDevice(device); |
| | | log.info("orderType{}", deviceOrder.getOrderType()); |
| | | System.out.println(deviceOrder.getOrderType()); |
| | | //更新订单的用户信息 |
| | | SysUser sysUser = getLoginUser().getUser(); |
| | | deviceOrder.setCreateUserId(sysUser.getUserId()); |
| | | //插入维修单 |
| | | int rows = iDeviceOrderService.insertDeviceOrder(deviceOrder); |
| | | if (rows > 0) { |
| | | Device device1 = deviceService.selectDeviceByDeviceId(deviceOrder.getDeviceId()); |
| | | //更新当前设备的是否维修信息-未维修 |
| | | Device device = new Device(); |
| | | device.setDeviceId(deviceOrder.getDeviceId()); |
| | | device.setRepairFlag(1); |
| | | device.setStatus(device1.getStatus()); |
| | | deviceService.updateDevice(device); |
| | | } |
| | | return toAjax(rows); |
| | | } |
| | | //更新订单的用户信息 |
| | | SysUser sysUser = getLoginUser().getUser(); |
| | |
| | | @Log(title = "修改设备订单信息", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody DeviceOrder deviceOrder) throws Exception { |
| | | //判断传过来的orderType的值是否为1-安装,并且安装单的状态为已完成,修改设备的状态为离线状态 |
| | | if ("1".equals(deviceOrder.getOrderType()) && deviceOrder.getState() == 3) { |
| | | Device device = new Device(); |
| | | device.setDeviceId(deviceOrder.getDeviceId()); |
| | | device.setStatus(4); |
| | | deviceService.updateDevice(device); |
| | | log.info("OrderType{}", deviceOrder.getOrderType()); |
| | | log.info("State{}", deviceOrder.getState()); |
| | | System.out.println(deviceOrder.getOrderType()); |
| | | System.out.println(deviceOrder.getState()); |
| | | //获取修改订单的用户信息 |
| | | SysUser sysUser = getLoginUser().getUser(); |
| | | //拿到修改安装单的用户id |
| | | deviceOrder.setUpdateUserId(sysUser.getUserId()); |
| | | deviceOrder.setFinishTime(new Date()); |
| | | int rows = iDeviceOrderService.updateDeviceOrder(deviceOrder); |
| | | if (rows > 0) { |
| | | Device device = new Device(); |
| | | device.setDeviceId(deviceOrder.getDeviceId()); |
| | | //修改设备的状态为离线 |
| | | device.setStatus(4); |
| | | deviceService.updateDevice(device); |
| | | } |
| | | return toAjax(rows); |
| | | } |
| | | //判断传过来的orderType的值是否为2-维修,并且维修单的状态为为已完成,修改设备的是否维修为0-已维修 |
| | | if ("2".equals(deviceOrder.getOrderType()) && deviceOrder.getState() == 3) { |
| | | Device device = new Device(); |
| | | device.setDeviceId(deviceOrder.getDeviceId()); |
| | | device.setRepairFlag(0); |
| | | log.info("OrderType{}", deviceOrder.getOrderType()); |
| | | log.info("State{}", deviceOrder.getState()); |
| | | System.out.println(deviceOrder.getOrderType()); |
| | | System.out.println(deviceOrder.getState()); |
| | | //获取修改订单的用户信息 |
| | | SysUser sysUser = getLoginUser().getUser(); |
| | | //拿到修维修单的用户id |
| | | deviceOrder.setUpdateUserId(sysUser.getUserId()); |
| | | deviceOrder.setFinishTime(new Date()); |
| | | int rows = iDeviceOrderService.updateDeviceOrder(deviceOrder); |
| | | if (rows > 0) { |
| | | Device device1 = deviceService.selectDeviceByDeviceId(deviceOrder.getDeviceId()); |
| | | Device device = new Device(); |
| | | device.setDeviceId(deviceOrder.getDeviceId()); |
| | | device.setRepairFlag(0); |
| | | device.setStatus(device1.getStatus()); |
| | | deviceService.updateDevice(device); |
| | | } |
| | | return toAjax(rows); |
| | | } |
| | | //获取修改订单的用户信息 |
| | | SysUser sysUser = getLoginUser().getUser(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 安装单维修单图片上传 |
| | | * 安装单/维修单图片上传 |
| | | * |
| | | * @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()) { |