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

feat(配套设备模块): 打印和更新标签

打印和更新标签
上级 59f63423
...@@ -717,33 +717,17 @@ public class MatchingDeviceController { ...@@ -717,33 +717,17 @@ public class MatchingDeviceController {
@PostMapping(value = "/print") @PostMapping(value = "/print")
@org.springframework.transaction.annotation.Transactional(rollbackFor = Exception.class) @org.springframework.transaction.annotation.Transactional(rollbackFor = Exception.class)
public ResponseEntity printRfid(@RequestBody List<RfidPrintVo> rfid) { public ResponseEntity printRfid(@RequestBody List<RfidPrintVo> rfid) {
Map<String, MatchingDeviceLibrary> map = matchingDeviceLibraryService.getAllMatchingDeviceSeqNumber(); matchingDeviceLibraryService.printRfid(rfid);
List<DeviceLogDto> deviceLogDtos = new ArrayList<>();
List<PrintVo> printVos = new ArrayList<>();
//调用打印服务 批量打印
for (RfidPrintVo printVo : rfid) {
MatchingDeviceLibrary matchingDeviceLibrary = map.get(printVo.getMatchingDeviceSeq());
PrintVo printVo1 = new PrintVo(RfidServiceImpl.completeRfidStr(
String.valueOf(matchingDeviceLibrary.getId())),
matchingDeviceLibrary.getModel(),
matchingDeviceLibrary.getName(),
matchingDeviceLibrary.getSeqNumber());
printVos.add(printVo1);
if ("".equals(matchingDeviceLibrary.getRfidCardId())) {
matchingDeviceLibrary.setRfidCardId(RfidServiceImpl.completeRfidStr(
String.valueOf(matchingDeviceLibrary.getId())));
matchingDeviceLibraryService.update(matchingDeviceLibrary);
deviceLogDtos.add(new DeviceLogDto(matchingDeviceLibrary.getId(), "打印标签", null,null,null));
}
else {
deviceLogDtos.add(new DeviceLogDto(matchingDeviceLibrary.getId(), "更换标签", null,null,null));
}
}
rfidService.printString(printVos.stream().sorted(Comparator.comparing(PrintVo::getRfidContent)).collect(Collectors.toList()));
deviceLogService.addAllLog(deviceLogDtos);
return ResultUtil.success("打印成功"); return ResultUtil.success("打印成功");
} }
@ApiOperation(value = "打印或者更新rfid", notes = "打印rfid")
@GetMapping("/print/matchingDeviceId")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity printRfid(Integer id) {
MatchingDeviceLibrary matchingDeviceLibrary = matchingDeviceLibraryService.printRfid(id);
return ResponseEntity.ok(matchingDeviceLibrary.getRfidCardId());
}
/** /**
* @return 生成配套设备附件的序列号 * @return 生成配套设备附件的序列号
*/ */
......
...@@ -5,6 +5,7 @@ import com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo; ...@@ -5,6 +5,7 @@ import com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo;
import com.tykj.dev.device.matching.subject.domin.MatchingDeviceLibrary; import com.tykj.dev.device.matching.subject.domin.MatchingDeviceLibrary;
import com.tykj.dev.device.matching.subject.vo.MatchingDeviceSelectVo; import com.tykj.dev.device.matching.subject.vo.MatchingDeviceSelectVo;
import com.tykj.dev.device.matching.subject.vo.RelationDeviceVo; import com.tykj.dev.device.matching.subject.vo.RelationDeviceVo;
import com.tykj.dev.rfid.entity.vo.RfidPrintVo;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
...@@ -80,4 +81,15 @@ public interface MatchingDeviceLibraryService { ...@@ -80,4 +81,15 @@ public interface MatchingDeviceLibraryService {
* 获取配套设备的序列号 * 获取配套设备的序列号
*/ */
Map<String,MatchingDeviceLibrary> getAllMatchingDeviceSeqNumber(); Map<String,MatchingDeviceLibrary> getAllMatchingDeviceSeqNumber();
/**
* 打印标签
*/
void printRfid(List<RfidPrintVo> rfid);
/**
* 打印或者更新标签
* @param matchingDeviceId 配套设备的id
*/
MatchingDeviceLibrary printRfid(Integer matchingDeviceId);
} }
...@@ -5,6 +5,8 @@ import com.github.wenhao.jpa.Specifications; ...@@ -5,6 +5,8 @@ import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.blockcha.subject.entity.BcHash; import com.tykj.dev.blockcha.subject.entity.BcHash;
import com.tykj.dev.blockcha.subject.service.BlockChainUtil; import com.tykj.dev.blockcha.subject.service.BlockChainUtil;
import com.tykj.dev.config.TaskBeanConfig; import com.tykj.dev.config.TaskBeanConfig;
import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.service.DeviceLogService;
import com.tykj.dev.device.library.subject.Dto.DeviceLogDto; 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.domin.DeviceLibrary;
import com.tykj.dev.device.matching.repository.MatchingDeviceLibraryDao; import com.tykj.dev.device.matching.repository.MatchingDeviceLibraryDao;
...@@ -18,11 +20,18 @@ import com.tykj.dev.misc.exception.ApiException; ...@@ -18,11 +20,18 @@ import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.utils.JacksonUtil; import com.tykj.dev.misc.utils.JacksonUtil;
import com.tykj.dev.misc.utils.PageUtil; import com.tykj.dev.misc.utils.PageUtil;
import com.tykj.dev.misc.utils.ResultUtil; import com.tykj.dev.misc.utils.ResultUtil;
import com.tykj.dev.rfid.entity.vo.PrintVo;
import com.tykj.dev.rfid.entity.vo.RfidPrintVo;
import com.tykj.dev.rfid.service.RfidService;
import com.tykj.dev.rfid.service.impl.RfidServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import javax.persistence.Transient; import javax.persistence.Transient;
import java.lang.reflect.Field; import java.lang.reflect.Field;
...@@ -49,6 +58,12 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe ...@@ -49,6 +58,12 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe
@Autowired @Autowired
private BlockChainUtil blockChainUtil; private BlockChainUtil blockChainUtil;
@Autowired
private DeviceLogService deviceLogService;
@Autowired
private RfidService rfidService;
@Override @Override
public MatchingDeviceLibrary addEntity(MatchingDeviceLibrary matchingDeviceLibraryEntity) { public MatchingDeviceLibrary addEntity(MatchingDeviceLibrary matchingDeviceLibraryEntity) {
MatchingDeviceLibrary matchingDeviceLibrary = matchingDeviceLibraryDao.save(matchingDeviceLibraryEntity); MatchingDeviceLibrary matchingDeviceLibrary = matchingDeviceLibraryDao.save(matchingDeviceLibraryEntity);
...@@ -235,6 +250,65 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe ...@@ -235,6 +250,65 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe
MatchingDeviceLibrary::getSeqNumber, Function.identity())); MatchingDeviceLibrary::getSeqNumber, Function.identity()));
} }
@Override
public void printRfid(List<RfidPrintVo> rfid) {
Map<String, MatchingDeviceLibrary> map = getAllMatchingDeviceSeqNumber();
List<DeviceLogDto> deviceLogDtos = new ArrayList<>();
List<PrintVo> printVos = new ArrayList<>();
//调用打印服务 批量打印
for (RfidPrintVo printVo : rfid) {
MatchingDeviceLibrary matchingDeviceLibrary = map.get(printVo.getMatchingDeviceSeq());
PrintVo printVo1 = new PrintVo(RfidServiceImpl.completeRfidStr(
matchingDeviceLibrary.getSeqNumber()),
matchingDeviceLibrary.getModel(),
matchingDeviceLibrary.getName(),
matchingDeviceLibrary.getSeqNumber());
printVos.add(printVo1);
if ("".equals(matchingDeviceLibrary.getRfidCardId())) {
matchingDeviceLibrary.setRfidCardId(RfidServiceImpl.completeRfidStr(
matchingDeviceLibrary.getSeqNumber()));
update(matchingDeviceLibrary);
deviceLogDtos.add(new DeviceLogDto(matchingDeviceLibrary.getId(), "打印标签",
null,null,null));
}
else {
deviceLogDtos.add(new DeviceLogDto(matchingDeviceLibrary.getId(), "更换标签",
null,null,null));
}
}
rfidService.printString(printVos.stream().sorted(Comparator.comparing(PrintVo::getRfidContent))
.collect(Collectors.toList()));
deviceLogService.addAllLog(deviceLogDtos);
}
@Override
public MatchingDeviceLibrary printRfid(Integer matchingDeviceId) {
MatchingDeviceLibrary matchingDeviceLibrary = getOne(matchingDeviceId);
DeviceLogDto deviceLogDto = null;
// List<PrintVo> printVos = new ArrayList<>();
PrintVo printVo1 = new PrintVo(RfidServiceImpl.completeRfidStr(
matchingDeviceLibrary.getSeqNumber()), matchingDeviceLibrary.getModel(),
matchingDeviceLibrary.getName(), matchingDeviceLibrary.getSeqNumber());
if ("".equals(matchingDeviceLibrary.getRfidCardId())) {
matchingDeviceLibrary.setRfidCardId(RfidServiceImpl.completeRfidStr(matchingDeviceLibrary.getSeqNumber()));
if (rfidService.printString1(printVo1)){
update(matchingDeviceLibrary);
deviceLogDto = new DeviceLogDto(matchingDeviceLibrary.getId(), "打印标签", null, null, null);
}
}
else {
rfidService.printString1(printVo1);
deviceLogDto = new DeviceLogDto(matchingDeviceLibrary.getId(), "更新标签", null, null, null);
}
// printVos.add(printVo1);
// rfidService.printString(printVos.stream().sorted(Comparator.comparing(PrintVo::getRfidContent)).collect(Collectors.toList()));
deviceLogService.addLog(deviceLogDto);
return matchingDeviceLibrary;
}
/** /**
* @param matchingDeviceSelectVo 配套设备查询vo * @param matchingDeviceSelectVo 配套设备查询vo
* 创建通用查询条件筛选器 * 创建通用查询条件筛选器
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论