Browse Source

# 设备信息编码生成添加前缀

# 设备信息查询列表获取站点信息代码优化
zhongwei
haungxing 2 years ago
parent
commit
c2d356210f
  1. 20
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java
  2. 7
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java

20
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java

@ -93,17 +93,17 @@ public class EmInfoController extends BladeController {
QueryWrapper<EmInfoEntity> queryWrapper = Condition.getQueryWrapper(em_info, EmInfoEntity.class);
queryWrapper.lambda().eq(EmInfoEntity::getGpid, 0);
IPage<EmInfoEntity> pages = em_infoService.page(Condition.getPage(query), queryWrapper);
if(CollectionUtil.isNotEmpty(pages.getRecords())) {
// 获取站点列表 - 填充站点编码、站点类型、站点名称
R<List<StationEntity>> stationListR = stationClient.getListAll();
if(stationListR.isSuccess() && CollectionUtil.isNotEmpty(stationListR.getData())) {
List<StationEntity> stationList = stationListR.getData();
pages.getRecords().forEach(emInfoEntity -> {
if(Func.isNotEmpty(emInfoEntity.getDepartment())) {
StationEntity request = new StationEntity();
request.setRefDept(emInfoEntity.getDepartment());
R<StationEntity> result = stationClient.getOne(request);
if(result.isSuccess() && ObjectUtil.isNotEmpty(result.getData())) {
emInfoEntity.setStationCode(result.getData().getCode());
emInfoEntity.setStationType(result.getData().getType());
emInfoEntity.setStationName(result.getData().getName());
}
Optional<StationEntity> stationOptional = stationList.stream().filter(station -> station.getRefDept().equals(emInfoEntity.getDepartment())).findAny();
if(stationOptional.isPresent()) {
StationEntity stationEntity = stationOptional.get();
emInfoEntity.setStationCode(stationEntity.getCode());
emInfoEntity.setStationType(stationEntity.getType());
emInfoEntity.setStationName(stationEntity.getName());
}
});
}

7
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java

@ -75,6 +75,9 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
@Value("${hzims.equipment.emInfo.emInfoList}")
public String em_info_list_path;
@Value("${hzims.equipment.emInfo.code-prefix}")
public String emInfoCodePrefix;
@Override
public R<EmInfoEntity> getEmInfoByCode(String emCode) {
EmInfoNoScopeMapper mapper = SpringUtil.getBean("emInfoNoScopeMapper");
@ -108,7 +111,7 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
// 验证设备信息
this.validEmInfo(em_info);
EmInfoEntity infoEntity = em_info.getInfo();
infoEntity.setNumber(Long.toString(IdWorker.getId()));
infoEntity.setNumber(emInfoCodePrefix + IdWorker.getId());
if (this.save(infoEntity)) {
this.getStationCodeStoreRedis();
Long infoId = em_info.getInfo().getId();
@ -477,7 +480,7 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
// 验证设备序号
if(Func.isNotEmpty(em_info.getInfo().getEmIndex())) {
List<EmInfoEntity> exist = super.list(Wrappers.<EmInfoEntity>lambdaQuery()
.eq(EmInfoEntity::getCreateDept, AuthUtil.getDeptId())
.eq(EmInfoEntity::getDepartment, em_info.getInfo().getDepartment())
.eq(EmInfoEntity::getEmIndex, em_info.getInfo().getEmIndex())
);
Assert.isTrue(CollectionUtil.isEmpty(exist),() -> {

Loading…
Cancel
Save