|
@@ -1,13 +1,18 @@
|
|
package com.xy.service;
|
|
package com.xy.service;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.xy.collections.list.JArrayList;
|
|
import com.xy.collections.list.JArrayList;
|
|
import com.xy.collections.map.JMap;
|
|
import com.xy.collections.map.JMap;
|
|
|
|
+import com.xy.consts.CommConsts;
|
|
import com.xy.dto.DeviceFaultInfoDto;
|
|
import com.xy.dto.DeviceFaultInfoDto;
|
|
|
|
+import com.xy.dto.DeviceFaultInfoFlowDto;
|
|
|
|
+import com.xy.dto.SysWorkUser.ListDto;
|
|
|
|
+import com.xy.dto.SysWorkUser.SysWorkVo;
|
|
import com.xy.dto.be.MercDto;
|
|
import com.xy.dto.be.MercDto;
|
|
import com.xy.entity.DeviceFaultInfo;
|
|
import com.xy.entity.DeviceFaultInfo;
|
|
import com.xy.entity.DeviceFaultLog;
|
|
import com.xy.entity.DeviceFaultLog;
|
|
@@ -15,14 +20,12 @@ import com.xy.entity.DeviceInfo;
|
|
import com.xy.error.CommRuntimeException;
|
|
import com.xy.error.CommRuntimeException;
|
|
import com.xy.mapper.DeviceFaultInfoMapper;
|
|
import com.xy.mapper.DeviceFaultInfoMapper;
|
|
import com.xy.service.be.MercService;
|
|
import com.xy.service.be.MercService;
|
|
-import com.xy.utils.Emptys;
|
|
|
|
-import com.xy.utils.MybatisPlusQuery;
|
|
|
|
-import com.xy.utils.PageBean;
|
|
|
|
-import com.xy.utils.R;
|
|
|
|
|
|
+import com.xy.utils.*;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -52,6 +55,8 @@ public class DeviceFaultInfoServiceImpl extends ServiceImpl<DeviceFaultInfoMappe
|
|
private final DeviceFaultLogServiceImpl deviceFaultLogService;
|
|
private final DeviceFaultLogServiceImpl deviceFaultLogService;
|
|
private final MercService mercService;
|
|
private final MercService mercService;
|
|
private final DeviceInfoServiceImpl deviceInfoService;
|
|
private final DeviceInfoServiceImpl deviceInfoService;
|
|
|
|
+ private final DeviceFaultInfoFlowServiceImpl deviceFaultInfoFlowService;
|
|
|
|
+ private final SysWorkUserService sysWorkUserService;
|
|
|
|
|
|
@PostMapping("obj")
|
|
@PostMapping("obj")
|
|
@ApiOperation("对象查询")
|
|
@ApiOperation("对象查询")
|
|
@@ -82,6 +87,14 @@ public class DeviceFaultInfoServiceImpl extends ServiceImpl<DeviceFaultInfoMappe
|
|
.eqWrapper(page, DeviceFaultInfo.class).build()
|
|
.eqWrapper(page, DeviceFaultInfo.class).build()
|
|
.ge(beginTime != null, DeviceFaultInfo::getCreateTime, beginTime)
|
|
.ge(beginTime != null, DeviceFaultInfo::getCreateTime, beginTime)
|
|
.le(endTime != null, DeviceFaultInfo::getCreateTime, endTime);
|
|
.le(endTime != null, DeviceFaultInfo::getCreateTime, endTime);
|
|
|
|
+
|
|
|
|
+ Long sysId = AuthorizeUtils.getSysId();
|
|
|
|
+ List<String> roleCodes = AuthorizeUtils.getRoleCodes(sysId);
|
|
|
|
+ //售后角色只看转售后的,其他角色看所有
|
|
|
|
+ if(roleCodes.contains(CommConsts.MERC_SH_ADMIN)){
|
|
|
|
+ lambdaQueryWrapper.eq(DeviceFaultInfo::getToAfterSale,true);
|
|
|
|
+ }
|
|
|
|
+
|
|
IPage<DeviceFaultInfo> iPage = page(toIPage(pageBean), lambdaQueryWrapper);
|
|
IPage<DeviceFaultInfo> iPage = page(toIPage(pageBean), lambdaQueryWrapper);
|
|
PageBean<DeviceFaultInfoDto.Vo> data = toPageBean(DeviceFaultInfoDto.Vo.class, iPage);
|
|
PageBean<DeviceFaultInfoDto.Vo> data = toPageBean(DeviceFaultInfoDto.Vo.class, iPage);
|
|
List<DeviceFaultInfoDto.Vo> records = data.getRecords();
|
|
List<DeviceFaultInfoDto.Vo> records = data.getRecords();
|
|
@@ -120,20 +133,30 @@ public class DeviceFaultInfoServiceImpl extends ServiceImpl<DeviceFaultInfoMappe
|
|
@PostMapping("resolve")
|
|
@PostMapping("resolve")
|
|
@ApiOperation("标记已解决")
|
|
@ApiOperation("标记已解决")
|
|
public R resolve(@RequestBody @Validated DeviceFaultInfoDto.Update update) {
|
|
public R resolve(@RequestBody @Validated DeviceFaultInfoDto.Update update) {
|
|
- DeviceFaultInfo deviceFaultInfo = this.getById(update.getFaultId());
|
|
|
|
|
|
+ resolveDone(update);
|
|
|
|
+ return R.ok();
|
|
|
|
+ }
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public void resolveDone( DeviceFaultInfoDto.Update update){
|
|
|
|
+ Long faultId = update.getFaultId();
|
|
|
|
+ DeviceFaultInfo deviceFaultInfo = this.getById(faultId);
|
|
if (deviceFaultInfo == null) {
|
|
if (deviceFaultInfo == null) {
|
|
throw new CommRuntimeException("操作对象不存在!");
|
|
throw new CommRuntimeException("操作对象不存在!");
|
|
}
|
|
}
|
|
DeviceFaultInfo updateInfo = copy(DeviceFaultInfo.class, update);
|
|
DeviceFaultInfo updateInfo = copy(DeviceFaultInfo.class, update);
|
|
updateInfo.setState(true);
|
|
updateInfo.setState(true);
|
|
|
|
+ updateInfo.setResolveTime(LocalDateTime.now());
|
|
updateInfo.setFaultLevel(-1);
|
|
updateInfo.setFaultLevel(-1);
|
|
boolean b = updateById(updateInfo);
|
|
boolean b = updateById(updateInfo);
|
|
if (b) {
|
|
if (b) {
|
|
|
|
+ DeviceFaultInfoFlowDto.Save save = new DeviceFaultInfoFlowDto.Save();
|
|
|
|
+ save.setFaultId(faultId);
|
|
|
|
+ save.setContent("故障已解决");
|
|
|
|
+ deviceFaultInfoFlowService.save(save);
|
|
//清理日志 故障信息表标记已解决,清除日志表中对应设备事件在标记已解决时间之前所有事件。
|
|
//清理日志 故障信息表标记已解决,清除日志表中对应设备事件在标记已解决时间之前所有事件。
|
|
deviceFaultLogService.remove(Wrappers.<DeviceFaultLog>lambdaUpdate().le(DeviceFaultLog::getEventTime, LocalDateTime.now()));
|
|
deviceFaultLogService.remove(Wrappers.<DeviceFaultLog>lambdaUpdate().le(DeviceFaultLog::getEventTime, LocalDateTime.now()));
|
|
//更新故障等级为正常
|
|
//更新故障等级为正常
|
|
deviceInfoService.updateById(new DeviceInfo().setDeviceId(deviceFaultInfo.getDeviceId()).setFaultLevel(-1));
|
|
deviceInfoService.updateById(new DeviceInfo().setDeviceId(deviceFaultInfo.getDeviceId()).setFaultLevel(-1));
|
|
}
|
|
}
|
|
- return R.ok();
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|