xinwei #3
@ -14,7 +14,7 @@ public class AssetRespVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "30538")
|
||||
@ExcelProperty("ID")
|
||||
private Long id;
|
||||
private String id;
|
||||
|
||||
@Schema(description = "数据ID", example = "15059")
|
||||
@ExcelProperty("数据ID")
|
||||
|
@ -1,17 +1,16 @@
|
||||
package cn.iocoder.yudao.module.datacenter.service.asset;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.admin.asset.vo.AssetRespVO;
|
||||
import cn.iocoder.yudao.module.datacenter.dal.dataobject.asset.Asset;
|
||||
import cn.iocoder.yudao.module.datacenter.dal.mongodb.asset.AssetRepository;
|
||||
import com.baomidou.dynamic.datasource.annotation.Slave;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
@ -52,7 +51,7 @@ public class AssetServiceImpl implements AssetService {
|
||||
map.put("手持机", String.valueOf(assetTypeCounts[2]));
|
||||
List<Map<String,String>>mapList=new ArrayList<>();
|
||||
for (Map.Entry<String, String> stringStringEntry : map.entrySet()) {
|
||||
Map map1=new LinkedHashMap();
|
||||
Map<String, String> map1=new LinkedHashMap<>();
|
||||
map1.put("assettype",stringStringEntry.getKey());
|
||||
map1.put("count",stringStringEntry.getValue());
|
||||
mapList.add(map1);
|
||||
@ -64,13 +63,7 @@ public class AssetServiceImpl implements AssetService {
|
||||
public List<AssetRespVO> nameAsset(String assettypename) {
|
||||
List<AssetRespVO> assetRespVOList = new ArrayList<>();
|
||||
for (Asset assetDO : assetRepository.findAllByAssettypename(assettypename)) {
|
||||
AssetRespVO assetRespVO = new AssetRespVO();
|
||||
assetRespVO.setId(Long.valueOf(assetDO.getId()));
|
||||
assetRespVO.setDataId(assetDO.getDataId());
|
||||
assetRespVO.setAssetname(assetDO.getAssetname());
|
||||
assetRespVO.setAssettype(assetDO.getAssettype());
|
||||
assetRespVO.setAssettypename(assetDO.getAssettypename());
|
||||
assetRespVO.setIsOnline(assetDO.getIsOnline());
|
||||
AssetRespVO assetRespVO = BeanUtils.toBean(assetDO, AssetRespVO.class);
|
||||
if (assetDO.getLastFeedbackTime() != null) {
|
||||
assetRespVO.setLastfeedbacktime(assetDO.getLastFeedbackTime());
|
||||
}
|
||||
|
@ -9,6 +9,9 @@ import cn.iocoder.yudao.module.ticket.dal.mongodb.checkticket.CheckTicketReposit
|
||||
import com.baomidou.dynamic.datasource.annotation.Slave;
|
||||
import com.mongodb.MongoException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.ExampleMatcher;
|
||||
import org.springframework.data.mongodb.repository.Query;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -23,13 +26,11 @@ import cn.iocoder.yudao.module.ticket.dal.mysql.checkticket.CheckTicketMapper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.ticket.enums.ErrorCodeConstants.*;
|
||||
import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.exact;
|
||||
|
||||
/**
|
||||
* 检票 Service 实现类
|
||||
@ -47,6 +48,7 @@ public class CheckTicketServiceImpl implements CheckTicketService {
|
||||
|
||||
@Override
|
||||
public Long createCheckTicket(CheckTicketSaveReqVO createReqVO) {
|
||||
if (isExistDataId(createReqVO.getDataId())) return 0L;
|
||||
// 插入
|
||||
CheckTicketDO checkTicket = BeanUtils.toBean(createReqVO, CheckTicketDO.class);
|
||||
checkTicketMapper.insert(checkTicket);
|
||||
@ -71,6 +73,10 @@ public class CheckTicketServiceImpl implements CheckTicketService {
|
||||
checkTicketMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private Boolean isExistDataId(String dataId) {
|
||||
return checkTicketMapper.selectOne("data_id", dataId) != null;
|
||||
}
|
||||
|
||||
private void validateCheckTicketExists(Long id) {
|
||||
if (checkTicketMapper.selectById(id) == null) {
|
||||
throw exception(CHECK_TICKET_NOT_EXISTS);
|
||||
@ -124,13 +130,22 @@ public class CheckTicketServiceImpl implements CheckTicketService {
|
||||
@Override
|
||||
public String createCheckTicketByMongoDB(CheckTicketSaveReqDTO checkTicketSaveReqDTO) {
|
||||
CheckTicket checkTicket = BeanUtils.toBean(checkTicketSaveReqDTO, CheckTicket.class);
|
||||
try {
|
||||
checkTicketRepository.findOne(Example.of(checkTicket, ExampleMatcher.matching().
|
||||
withIgnorePaths("_id").withMatcher("dataId", exact())));
|
||||
return "重复数据";
|
||||
} catch (NoSuchElementException e) {
|
||||
try {
|
||||
// 执行插入操作
|
||||
checkTicketRepository.insert(checkTicket);
|
||||
return "添加成功";
|
||||
} catch (MongoException e){
|
||||
} catch (MongoException e2) {
|
||||
return "Mongo数据库写入异常";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user