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

feat(日常检查模块): 添加了识别二维码的时候做一个校验

添加了识别二维码的时候做一个校验
上级 2c55546a
......@@ -103,8 +103,8 @@ public class DailyCheckController {
@ApiOperation(value = "解析二维码", notes = "解析二维码")
@PostMapping(value = "/parseQrCode")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity parseQrCode(@RequestBody List<String> strings){
List<DeviceLibrary> deviceLibraries = dailyCheckBillService.parseQrCode(strings);
public ResponseEntity parseQrCode(@RequestBody ParseQrCodeVO parseQrCodeVO){
List<DeviceLibrary> deviceLibraries = dailyCheckBillService.parseQrCode(parseQrCodeVO);
deviceLibraries.forEach(DeviceLibrary::setConfigName);
return ResponseEntity.ok(deviceLibraries);
}
......@@ -174,9 +174,11 @@ public class DailyCheckController {
String dayDeviceList = checkUnitBill.getDayDeviceList();
String[] ids = dayDeviceList.split("x");
List<Integer> deviceIds = new ArrayList<>();
for (int i = 0; i < ids.length; i++) {
int i1 = Integer.parseInt(ids[i]);
deviceIds.add(i1);
if (ids.length >0){
for (int i = 0; i < ids.length; i++) {
int i1 = Integer.parseInt(ids[i]);
deviceIds.add(i1);
}
}
List<DeviceLibrary> deviceLibraryList = deviceLibraryService.findAllByIds(deviceIds);
deviceLibraryList.forEach(DeviceLibrary::setConfigName);
......
......@@ -1044,21 +1044,37 @@ public class SelfCheckController {
@PostMapping("/selectCheckDeviceList")
public ResponseEntity selectDeviceList(@RequestBody SelfCheckVo selfCheckVo) {
Integer selfBillId = selfCheckVo.getSelfBillId();
Integer storageLocationId = null;
if(selfBillId != null){
SelfCheckBill checkBill = selfCheckBillService.getOne(selfBillId);
storageLocationId = checkBill.getStorageLocationId();
}
Integer storageLocationId = selfCheckVo.getStorageLocationId();
String unit = userUtils.getCurrentUserUnitName();
PredicateBuilder<DeviceLibrary> predicateBuilder = Specifications.and();
predicateBuilder.eq("locationUnit", unit);
if (selfCheckVo.getStorageLocationId() != null){
predicateBuilder.eq(selfCheckVo.getStorageLocationId()!=null,"storageLocationId",selfCheckVo.getStorageLocationId());
} else {
if (storageLocationId != null){
if(selfBillId != null){
SelfCheckBill checkBill = selfCheckBillService.getOne(selfBillId);
Integer storageLocationId1 = checkBill.getStorageLocationId();
if (storageLocationId1 != 0){
predicateBuilder.eq("storageLocationId",storageLocationId1);
}
}else {
//说明直接传递的是库房
if (storageLocationId != 0){
predicateBuilder.eq("storageLocationId",storageLocationId);
}
}
// Integer storageLocationId = 0;
// if(selfBillId != null){
// SelfCheckBill checkBill = selfCheckBillService.getOne(selfBillId);
// storageLocationId = checkBill.getStorageLocationId();
// }
// String unit = userUtils.getCurrentUserUnitName();
// PredicateBuilder<DeviceLibrary> predicateBuilder = Specifications.and();
// predicateBuilder.eq("locationUnit", unit);
// if (selfCheckVo.getStorageLocationId() != 0){
// predicateBuilder.eq(selfCheckVo.getStorageLocationId()!=0,"storageLocationId",selfCheckVo.getStorageLocationId());
// } else {
// if (storageLocationId != null){
// predicateBuilder.eq("storageLocationId",storageLocationId);
// }
// }
List<Integer> status = new ArrayList<>(Arrays.asList(5,10,12));
List<DeviceLibrary> deviceLibraries = deviceLibraryDao.findAll(predicateBuilder.build())
.stream().filter(deviceLibrary -> !status.contains(deviceLibrary.getLifeStatus())).collect(Collectors.toList());
......
......@@ -68,7 +68,7 @@ public interface DailyCheckBillService {
* 解析二维码
* @return 返回检验后的设备数据
*/
List<DeviceLibrary> parseQrCode(List<String> strings);
List<DeviceLibrary> parseQrCode(ParseQrCodeVO parseQrCodeVO);
/**
* 根据业务id查询详情
......
......@@ -204,11 +204,21 @@ public class DailyCheckBillServiceImpl implements DailyCheckBillService {
}
@Override
public List<DeviceLibrary> parseQrCode(List<String> strings) {
public List<DeviceLibrary> parseQrCode(ParseQrCodeVO parseQrCodeVO) {
List<String> codeList = parseQrCodeVO.getCodeList();
//总的装备集合 返回给前端
TaskData taskData = qrCodeBillUtil.parseCode(strings);
TaskData taskData = qrCodeBillUtil.parseCode(codeList);
List<DeviceLibrary> deviceLibraries = new ArrayList<>();
if (taskData != null) {
//判断是不是当天的任务
LocalDate todayDate = DateUtil.getLocalDate(new Date());
Date taskCreateDate = taskData.getTaskCreateDate();
LocalDate taskDate = DateUtil.getLocalDate(taskCreateDate);
if (!todayDate.equals(taskDate)){
throw new ApiException("扫描任务与当前的任务时间不一致");
}
List<DeviceCodeVO> deviceLibraryList = taskData.getDeviceLibraries();
//0 缺失
List<DeviceCodeVO> libraryList =
......@@ -243,6 +253,25 @@ public class DailyCheckBillServiceImpl implements DailyCheckBillService {
deviceLibraryList1.forEach(deviceLibrary -> deviceLibrary.setCheckResult(2));
deviceLibraries.addAll(deviceLibraryList1);
}
List<Integer> deviceIds = deviceLibraries.stream().map(DeviceLibrary::getId).distinct().collect(Collectors.toList());
Integer dailyCheckId = parseQrCodeVO.getDailyCheckId();
DailyCheckBill checkBill = getOne(dailyCheckId);
String[] ids = checkBill.getCheckDetail().split(",");
List<Integer> finalIds = new ArrayList<>();
for (int i = 0; i < ids.length; i++) {
int j = Integer.parseInt(ids[i]);
finalIds.add(j);
}
if (deviceIds.size() != ids.length){
throw new ApiException("扫描任务与当前的任务时间不一致");
}else {
//长度一样
deviceIds.removeAll(finalIds);
if (deviceIds.size()>0){
throw new ApiException("扫描任务与当前的任务时间不一致");
}
}
}
return deviceLibraries;
}
......@@ -258,9 +287,12 @@ public class DailyCheckBillServiceImpl implements DailyCheckBillService {
String dayDeviceList = checkBill.getCheckDetail();
String[] ids = dayDeviceList.split(",");
List<Integer> deviceIds = new ArrayList<>();
for (int i = 0; i < ids.length; i++) {
int i1 = Integer.parseInt(ids[i]);
deviceIds.add(i1);
if (ids.length>0){
for (int i = 0; i < ids.length; i++) {
int i1 = Integer.parseInt(ids[i]);
deviceIds.add(i1);
}
}
List<DeviceLibrary> deviceLibraryList = deviceLibraryService.findAllByIds(deviceIds);
deviceLibraryList.forEach(DeviceLibrary::setConfigName);
......
......@@ -26,8 +26,8 @@ import java.util.List;
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update self_check_unit_bill set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
//@SQLDelete(sql = "update self_check_unit_bill set delete_tag = 1 where id = ?")
//@Where(clause = "delete_tag = 0")
@ApiModel("日常检查和单位的表")
public class SelfCheckUnitBill {
......@@ -74,8 +74,8 @@ public class SelfCheckUnitBill {
/**
* 删除标记(0:未删除,1:已删除)
*/
@ApiModelProperty(value = "删除标记(0:未删除,1:已删除)")
private Integer deleteTag = 0;
// @ApiModelProperty(value = "删除标记(0:未删除,1:已删除)")
// private Integer deleteTag = 0;
@Transient
......
package com.tykj.dev.device.selfcheck.subject.vo.daily;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author zsp
*/
@Data
@ApiModel("解析二维码的vo")
public class ParseQrCodeVO {
@ApiModelProperty(value = "二维码的内容")
private List<String> codeList;
@ApiModelProperty(value = "日常检查单据的id")
private Integer dailyCheckId;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论