提交 121f7c03 authored 作者: zhoushaopan's avatar zhoushaopan

feat(装备模块): 修改了缓存

修改了缓存
上级 a21c1ed8
...@@ -1183,6 +1183,16 @@ public class DeviceLibraryController { ...@@ -1183,6 +1183,16 @@ public class DeviceLibraryController {
return setOrderNumber(sortNum, allListAndParent); return setOrderNumber(sortNum, allListAndParent);
} }
@ApiOperation(value = "测试缓存", notes = "测试缓存")
@PostMapping("/testCache")
public ResponseEntity testCache(String seqNumber){
List<DeviceLibrary> allDeviceLibraryList = cacheLibraryService.getAllDeviceLibraryList();
List<DeviceLibrary> collect =
allDeviceLibraryList.stream().filter(deviceLibrary -> deviceLibrary.getSeqNumber().equals(seqNumber))
.collect(Collectors.toList());
return ResponseEntity.ok(collect);
}
@ApiOperation(value = "为工作交接查询装备", notes = "为工作交接查询装备") @ApiOperation(value = "为工作交接查询装备", notes = "为工作交接查询装备")
@GetMapping("/selectDeviceForWorkUse") @GetMapping("/selectDeviceForWorkUse")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
......
...@@ -22,6 +22,8 @@ public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>, ...@@ -22,6 +22,8 @@ public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>,
List<DeviceLibrary> findAllByIdIn(List<Integer> ids); List<DeviceLibrary> findAllByIdIn(List<Integer> ids);
List<DeviceLibrary> findAllByRfidCardIdIn(List<String> rfids);
List<DeviceLibrary> getAllByModel(String model); List<DeviceLibrary> getAllByModel(String model);
List<DeviceLibrary> getAllByOwnUnit(String unit); List<DeviceLibrary> getAllByOwnUnit(String unit);
...@@ -202,6 +204,8 @@ public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>, ...@@ -202,6 +204,8 @@ public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>,
List<DeviceLibrary> findByModelAndIsPart(String model,Integer isPart); List<DeviceLibrary> findByModelAndIsPart(String model,Integer isPart);
DeviceLibrary findByRfidCardIdAndOwnUnitOrLocationUnit(String rfid,String ownUnit,String localtionUnit);
List<DeviceLibrary> findAllByPartParentId(Integer partParentId); List<DeviceLibrary> findAllByPartParentId(Integer partParentId);
@Transactional @Transactional
......
...@@ -26,6 +26,5 @@ public interface DeviceLibraryCacheService { ...@@ -26,6 +26,5 @@ public interface DeviceLibraryCacheService {
void deletAllDeviceLibraryList(); void deletAllDeviceLibraryList();
void asyncUpdateCache();
} }
...@@ -519,4 +519,12 @@ public interface DeviceLibraryService { ...@@ -519,4 +519,12 @@ public interface DeviceLibraryService {
*/ */
List<DeviceLibrary> getDeviceByUnitNameAll(Integer unitId); List<DeviceLibrary> getDeviceByUnitNameAll(Integer unitId);
/**
* 根据id集合查询装备
* @param rfids 装备rfid的集合
*/
DeviceLibrary findRfId(String rfids);
List<DeviceLibrary> findAllByRfids(List<String> rfids);
} }
...@@ -68,17 +68,6 @@ public class CacheLibraryServiceImpl implements DeviceLibraryCacheService { ...@@ -68,17 +68,6 @@ public class CacheLibraryServiceImpl implements DeviceLibraryCacheService {
@Override @Override
@CacheEvict(key = "'device'",allEntries=true) @CacheEvict(key = "'device'",allEntries=true)
public void deletAllDeviceLibraryList() { public void deletAllDeviceLibraryList() {
// long l = System.currentTimeMillis();
// List<DeviceLibrary> all = deviceLibraryDao.findAll();
// System.out.println("更新缓存时间"+(System.currentTimeMillis()-l));
}
@Override
@CacheEvict(key = "'device'",allEntries=true)
public void asyncUpdateCache() {
executor.execute(()->{
deviceLibraryCacheService.getAllDeviceLibraryList();
});
} }
......
...@@ -17,6 +17,7 @@ import com.tykj.dev.device.library.subject.Dto.DeviceLogDto; ...@@ -17,6 +17,7 @@ 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.library.subject.vo.*; import com.tykj.dev.device.library.subject.vo.*;
import com.tykj.dev.device.library.utils.DeviceNumberUtils; import com.tykj.dev.device.library.utils.DeviceNumberUtils;
import com.tykj.dev.device.user.cache.UnitsCache;
import com.tykj.dev.device.user.subject.entity.Units; import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.device.user.subject.service.UnitsService; import com.tykj.dev.device.user.subject.service.UnitsService;
import com.tykj.dev.device.user.subject.service.UserPublicService; import com.tykj.dev.device.user.subject.service.UserPublicService;
...@@ -37,6 +38,7 @@ import org.springframework.scheduling.annotation.Async; ...@@ -37,6 +38,7 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import javax.persistence.Transient; import javax.persistence.Transient;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
...@@ -1223,6 +1225,20 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService { ...@@ -1223,6 +1225,20 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
return deviceLibraryDao.findAllByOwnUnitInOrLocationUnitIn(unitNames,unitNames); return deviceLibraryDao.findAllByOwnUnitInOrLocationUnitIn(unitNames,unitNames);
} }
@Resource
private UnitsCache unitsCache;
@Override
public DeviceLibrary findRfId(String rfids) {
Integer unitId = userUtils.getCurrentUnitId();
Units units = unitsCache.findById(unitId);
return deviceLibraryDao.findByRfidCardIdAndOwnUnitOrLocationUnit(rfids,units.getName(),units.getName());
}
@Override
public List<DeviceLibrary> findAllByRfids(List<String> rfids) {
return deviceLibraryDao.findAllByRfidCardIdIn(rfids);
}
// @Override // @Override
// @UpdateCache // @UpdateCache
// public int updatePartParentId(List<Integer> deviceIds) { // public int updatePartParentId(List<Integer> deviceIds) {
......
package com.tykj.dev.device.matching.controller; package com.tykj.dev.device.matching.controller;
import com.lowagie.text.pdf.SequenceList;
import com.tykj.dev.config.cache.ConfigCache; import com.tykj.dev.config.cache.ConfigCache;
import com.tykj.dev.config.swagger.AutoDocument; import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.file.entity.FileRet; import com.tykj.dev.device.file.entity.FileRet;
...@@ -12,8 +11,9 @@ import com.tykj.dev.device.library.subject.Dto.DeviceLogDto; ...@@ -12,8 +11,9 @@ 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.library.subject.domin.DeviceLog; import com.tykj.dev.device.library.subject.domin.DeviceLog;
import com.tykj.dev.device.library.subject.vo.*; import com.tykj.dev.device.library.subject.vo.*;
import com.tykj.dev.device.matching.repository.MatchingDeviceLibraryDao;
import com.tykj.dev.device.matching.repository.MatchingRepairBillDao; import com.tykj.dev.device.matching.repository.MatchingRepairBillDao;
import com.tykj.dev.device.matching.rfid.MatchingDeviceRfidService;
import com.tykj.dev.device.matching.rfid.MatchingDeviceRfidServiceImpl;
import com.tykj.dev.device.matching.service.MatchingDeviceBillService; import com.tykj.dev.device.matching.service.MatchingDeviceBillService;
import com.tykj.dev.device.matching.service.MatchingDeviceLibraryService; import com.tykj.dev.device.matching.service.MatchingDeviceLibraryService;
import com.tykj.dev.device.matching.service.MatchingDeviceModelService; import com.tykj.dev.device.matching.service.MatchingDeviceModelService;
...@@ -25,11 +25,9 @@ import com.tykj.dev.device.matching.subject.vo.*; ...@@ -25,11 +25,9 @@ import com.tykj.dev.device.matching.subject.vo.*;
import com.tykj.dev.device.task.service.TaskLogService; import com.tykj.dev.device.task.service.TaskLogService;
import com.tykj.dev.device.task.service.TaskService; import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.task.subject.bto.TaskBto; import com.tykj.dev.device.task.subject.bto.TaskBto;
import com.tykj.dev.device.task.subject.domin.Task;
import com.tykj.dev.device.user.cache.UnitsCache; import com.tykj.dev.device.user.cache.UnitsCache;
import com.tykj.dev.device.user.read.service.MessageService; import com.tykj.dev.device.user.read.service.MessageService;
import com.tykj.dev.device.user.read.subject.bto.MessageBto; import com.tykj.dev.device.user.read.subject.bto.MessageBto;
import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.device.user.subject.service.UnitsService; import com.tykj.dev.device.user.subject.service.UnitsService;
import com.tykj.dev.device.user.subject.service.UserPublicService; import com.tykj.dev.device.user.subject.service.UserPublicService;
import com.tykj.dev.device.user.util.UserUtils; import com.tykj.dev.device.user.util.UserUtils;
...@@ -39,8 +37,6 @@ import com.tykj.dev.misc.exception.ApiException; ...@@ -39,8 +37,6 @@ import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.utils.*; import com.tykj.dev.misc.utils.*;
import com.tykj.dev.rfid.entity.vo.PrintVo; import com.tykj.dev.rfid.entity.vo.PrintVo;
import com.tykj.dev.rfid.entity.vo.RfidPrintVo; import com.tykj.dev.rfid.entity.vo.RfidPrintVo;
import com.tykj.dev.rfid.service.RfidService;
import com.tykj.dev.rfid.service.impl.RfidServiceImpl;
import com.tykj.dev.socket.MyWebSocket; import com.tykj.dev.socket.MyWebSocket;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
...@@ -58,8 +54,6 @@ import javax.annotation.Resource; ...@@ -58,8 +54,6 @@ import javax.annotation.Resource;
import javax.validation.constraints.Min; import javax.validation.constraints.Min;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -112,7 +106,7 @@ public class MatchingDeviceController { ...@@ -112,7 +106,7 @@ public class MatchingDeviceController {
private MessageService messageService; private MessageService messageService;
@Autowired @Autowired
private RfidService rfidService; private MatchingDeviceRfidService matchingDeviceRfidService;
@Autowired @Autowired
private MatchingDeviceModelService matchingDeviceModelService; private MatchingDeviceModelService matchingDeviceModelService;
...@@ -243,10 +237,10 @@ public class MatchingDeviceController { ...@@ -243,10 +237,10 @@ public class MatchingDeviceController {
for (MatchingDeviceLibrary matchingDeviceLibrary : matchingDeviceLibraries) { for (MatchingDeviceLibrary matchingDeviceLibrary : matchingDeviceLibraries) {
printVos.add(new PrintVo(String.valueOf(matchingDeviceLibrary.getId()), matchingDeviceLibrary.getModel(), printVos.add(new PrintVo(String.valueOf(matchingDeviceLibrary.getId()), matchingDeviceLibrary.getModel(),
matchingDeviceLibrary.getName(),matchingDeviceLibrary.getSeqNumber())); matchingDeviceLibrary.getName(),matchingDeviceLibrary.getSeqNumber()));
matchingDeviceLibrary.setRfidCardId(RfidServiceImpl.completeRfidStr2(String.valueOf(matchingDeviceLibrary.getId()))); matchingDeviceLibrary.setRfidCardId(MatchingDeviceRfidServiceImpl.completeRfidStr2(String.valueOf(matchingDeviceLibrary.getId())));
matchingDeviceLibraryService.update(matchingDeviceLibrary); matchingDeviceLibraryService.update(matchingDeviceLibrary);
} }
rfidService.printString(printVos); matchingDeviceRfidService.printString(printVos);
} }
//set账单新增设备详情 //set账单新增设备详情
......
package com.tykj.dev.device.matching.rfid;
import com.tykj.dev.rfid.entity.vo.PrintVo;
import com.tykj.dev.rfid.entity.vo.QRCodePrintVo;
import com.tykj.dev.rfid.entity.vo.RfidCreateVo;
import com.tykj.dev.rfid.entity.vo.RfidPrintVo;
import java.util.List;
/**
* 描述:用于调用RFID打印机打印标签
*
* @author HuangXiahao
* @version V1.0
* @packageName com.tykj.equipmentrfid.service
**/
public interface MatchingDeviceRfidService {
/**
* 描述:设置打印机网络端口
*
* @param ip IP
* @param port 端口号
*/
void setNetWorkConnection(String ip, Integer port);
/**
* 描述:自动扫描本机的打印机接口
*/
void scanUsbConnection();
/**
* 描述:调用打印机打印内容(如出现打印不对齐的情况请联系管理员)
*
* @return
*/
boolean printString(List<PrintVo> printVos);
/**
* 描述:调用打印机打印内容(如出现打印不对齐的情况请联系管理员)
*
* @return
*/
boolean printString1(PrintVo printVo);
/**
* 描述:生成装备的RFID表面号
*
* @param list RFID表面号生成类
* @return
*/
List<RfidPrintVo> getRfidNumber(List<RfidCreateVo> list);
/**
* 条码打印机 批量打印
*/
void printByQRcode(List<QRCodePrintVo> qrCodePrintVos);
}
...@@ -8,6 +8,8 @@ import com.tykj.dev.config.TaskBeanConfig; ...@@ -8,6 +8,8 @@ import com.tykj.dev.config.TaskBeanConfig;
import com.tykj.dev.device.library.service.DeviceLogService; 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.matching.repository.MatchingDeviceLibraryDao; import com.tykj.dev.device.matching.repository.MatchingDeviceLibraryDao;
import com.tykj.dev.device.matching.rfid.MatchingDeviceRfidService;
import com.tykj.dev.device.matching.rfid.MatchingDeviceRfidServiceImpl;
import com.tykj.dev.device.matching.service.MatchingDeviceLibraryService; import com.tykj.dev.device.matching.service.MatchingDeviceLibraryService;
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.MatchingUnitVo; import com.tykj.dev.device.matching.subject.vo.MatchingUnitVo;
...@@ -24,8 +26,6 @@ import com.tykj.dev.misc.utils.PageUtil; ...@@ -24,8 +26,6 @@ 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.PrintVo;
import com.tykj.dev.rfid.entity.vo.RfidPrintVo; import com.tykj.dev.rfid.entity.vo.RfidPrintVo;
import com.tykj.dev.rfid.service.RfidService;
import com.tykj.dev.rfid.service.impl.RfidServiceImpl;
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;
...@@ -62,7 +62,7 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe ...@@ -62,7 +62,7 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe
private DeviceLogService deviceLogService; private DeviceLogService deviceLogService;
@Autowired @Autowired
private RfidService rfidService; private MatchingDeviceRfidService matchingDeviceRfidService;
@Resource @Resource
private UnitsCache unitsCache; private UnitsCache unitsCache;
...@@ -284,14 +284,14 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe ...@@ -284,14 +284,14 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe
//调用打印服务 批量打印 //调用打印服务 批量打印
for (RfidPrintVo printVo : rfid) { for (RfidPrintVo printVo : rfid) {
MatchingDeviceLibrary matchingDeviceLibrary = map.get(printVo.getMatchingDeviceSeq()); MatchingDeviceLibrary matchingDeviceLibrary = map.get(printVo.getMatchingDeviceSeq());
PrintVo printVo1 = new PrintVo(RfidServiceImpl.completeRfidStr( PrintVo printVo1 = new PrintVo(MatchingDeviceRfidServiceImpl.completeRfidStr(
matchingDeviceLibrary.getSeqNumber()), matchingDeviceLibrary.getSeqNumber()),
matchingDeviceLibrary.getModel(), matchingDeviceLibrary.getModel(),
matchingDeviceLibrary.getName(), matchingDeviceLibrary.getName(),
matchingDeviceLibrary.getSeqNumber()); matchingDeviceLibrary.getSeqNumber());
printVos.add(printVo1); printVos.add(printVo1);
if ("".equals(matchingDeviceLibrary.getRfidCardId())) { if ("".equals(matchingDeviceLibrary.getRfidCardId())) {
matchingDeviceLibrary.setRfidCardId(RfidServiceImpl.completeRfidStr( matchingDeviceLibrary.setRfidCardId(MatchingDeviceRfidServiceImpl.completeRfidStr(
matchingDeviceLibrary.getSeqNumber())); matchingDeviceLibrary.getSeqNumber()));
update(matchingDeviceLibrary); update(matchingDeviceLibrary);
deviceLogDtos.add(new DeviceLogDto(matchingDeviceLibrary.getId(), "打印标签", deviceLogDtos.add(new DeviceLogDto(matchingDeviceLibrary.getId(), "打印标签",
...@@ -302,7 +302,7 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe ...@@ -302,7 +302,7 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe
null,null,null)); null,null,null));
} }
} }
rfidService.printString(printVos.stream().sorted(Comparator.comparing(PrintVo::getRfidContent)) matchingDeviceRfidService.printString(printVos.stream().sorted(Comparator.comparing(PrintVo::getRfidContent))
.collect(Collectors.toList())); .collect(Collectors.toList()));
deviceLogService.addAllLog(deviceLogDtos); deviceLogService.addAllLog(deviceLogDtos);
} }
...@@ -312,18 +312,18 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe ...@@ -312,18 +312,18 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe
MatchingDeviceLibrary matchingDeviceLibrary = getOne(matchingDeviceId); MatchingDeviceLibrary matchingDeviceLibrary = getOne(matchingDeviceId);
DeviceLogDto deviceLogDto = null; DeviceLogDto deviceLogDto = null;
// List<PrintVo> printVos = new ArrayList<>(); // List<PrintVo> printVos = new ArrayList<>();
PrintVo printVo1 = new PrintVo(RfidServiceImpl.completeRfidStr( PrintVo printVo1 = new PrintVo(MatchingDeviceRfidServiceImpl.completeRfidStr(
matchingDeviceLibrary.getSeqNumber()), matchingDeviceLibrary.getModel(), matchingDeviceLibrary.getSeqNumber()), matchingDeviceLibrary.getModel(),
matchingDeviceLibrary.getName(), matchingDeviceLibrary.getSeqNumber()); matchingDeviceLibrary.getName(), matchingDeviceLibrary.getSeqNumber());
if ("".equals(matchingDeviceLibrary.getRfidCardId())) { if ("".equals(matchingDeviceLibrary.getRfidCardId())) {
matchingDeviceLibrary.setRfidCardId(RfidServiceImpl.completeRfidStr(matchingDeviceLibrary.getSeqNumber())); matchingDeviceLibrary.setRfidCardId(MatchingDeviceRfidServiceImpl.completeRfidStr(matchingDeviceLibrary.getSeqNumber()));
if (rfidService.printString1(printVo1)){ if (matchingDeviceRfidService.printString1(printVo1)){
update(matchingDeviceLibrary); update(matchingDeviceLibrary);
deviceLogDto = new DeviceLogDto(matchingDeviceLibrary.getId(), "打印标签", null, null, null); deviceLogDto = new DeviceLogDto(matchingDeviceLibrary.getId(), "打印标签", null, null, null);
} }
} }
else { else {
rfidService.printString1(printVo1); matchingDeviceRfidService.printString1(printVo1);
deviceLogDto = new DeviceLogDto(matchingDeviceLibrary.getId(), "更新标签", null, null, null); deviceLogDto = new DeviceLogDto(matchingDeviceLibrary.getId(), "更新标签", null, null, null);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论