提交 ef7729a2 authored 作者: zhoushaopan's avatar zhoushaopan

feat(装备模块): 新增了装备的校验接口

新增了装备的校验接口
上级 84f9df39
......@@ -11,6 +11,7 @@ import com.tykj.dev.device.file.service.FilesUtil;
import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.service.DeviceLogService;
import com.tykj.dev.device.library.service.VerificationService;
import com.tykj.dev.device.library.subject.Dto.DeviceLogDto;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.vo.FileVo;
......@@ -134,6 +135,9 @@ public class AllotBillController {
@Resource
private UnitsCache unitsCache;
@Resource
private VerificationService verificationService;
@ApiOperation(value = "导入二维码获取配发装备", notes = "可以通过这个接口导入二维码获取配发装备")
@PostMapping(value = "/load")
public ResponseEntity loadDevice(@RequestBody RfidVo rfidVo) {
......@@ -162,7 +166,9 @@ public class AllotBillController {
public ResponseEntity addAllotBill(@RequestBody @Validated AllotBillSaveVo allotBillSaveVo) {
//判断发起配发的装备的生命状态
if (allotBillSaveVo.getAllotCheckDetail() != null && allotBillSaveVo.getAllotCheckDetail().length() > 0) {
deviceLibraryService.isInStockOrWaitRetired(StringSplitUtil.split(allotBillSaveVo.getAllotCheckDetail()));
// deviceLibraryService.isInStockOrWaitRetired(StringSplitUtil.split(allotBillSaveVo.getAllotCheckDetail()));
//新增装备是否是自己的判断
verificationService.isLocal(StringSplitUtil.split(allotBillSaveVo.getAllotCheckDetail()));
}
//1.添加配发单
AllotBill a = allotBillSaveVo.toDo();
......
package com.tykj.dev.device.library.service;
import java.util.List;
/**
* @author zsp
* @create 2022/2/14 13:21
*/
public interface VerificationService {
/**
* 判断装备是否所在是不是自己(若不是抛出303异常)
* @param ids 装备ID的集合
*/
void isLocal(List<Integer> ids);
}
package com.tykj.dev.device.library.service.impl;
import com.tykj.dev.config.base.DeviceLifeStatus;
import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.service.VerificationService;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.exception.ApiException;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @author zsp
* @create 2022/2/14 13:25
*/
@Service
public class VerificationServiceImpl implements VerificationService {
@Resource
private DeviceLibraryService deviceLibraryService;
@Resource
private UserUtils userUtils;
@Override
public void isLocal(List<Integer> ids) {
String currentUserUnitName = userUtils.getCurrentUserUnitName();
ids.forEach(integer -> {
DeviceLibrary library = deviceLibraryService.getOne(integer);
if (library.getLifeStatus()!=2 && library.getLifeStatus()!=15&&library.getLifeStatus()!=14 && !library.getLifeStatus().equals(DeviceLifeStatus.SEND_BACK.id)){
throw new ApiException(ResponseEntity.status(303).body("序列号"+library.getSeqNumber()+"的装备已被其他专管员操作"));
}
if (!currentUserUnitName.equals(library.getLocationUnit())){
throw new ApiException(ResponseEntity.status(303).body("序列号"+library.getSeqNumber()+"的装备已被其他专管员操作"));
}
});
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论