赞
踩
List<GsFinalReport> gsFinalReports = ConvertUtil.convertList(result, GsFinalReport.class);
将数字转换为字符串;
List<String> lst = Arrays.asList("a","b","c");
String str = ArrayUtils.toString(lst);
System.out.println(a); //[a,b,c]
通过实体类mapper赛选出结果,在结果集中取某一字段的结果集。
List<String> collect = securityDeviceMapper.selectList(
new QueryWrapper<JcDSecurityDevice>()
.lambda().eq(JcDSecurityDevice::getDeleteState, 0))
.stream().map(JcDSecurityDevice::getImei).collect(Collectors.toList());
从数据库查询一个符合某些条件的实体;
//amsDAssetDataMapper : 实体对应的mapper,用于操作数据库
AmsDAssetData one = amsDAssetDataMapper.selectOne(
//AmsDAssetData :实体类名称
new QueryWrapper<AmsDAssetData>()
.lambda()
.eq(AmsDAssetData::getFacilityCode, request.getFacilityCode())
.eq(AmsDAssetData::getDeleteState, 0)
);
amsDAssetData.setCreateTime(new Date());
/** * 添加信息 * * @param addBmsSMaintainSchemeParam * @return */ @Override public void add(AddBmsSMaintainSchemeParam addBmsSMaintainSchemeParam) { BmsSMaintainScheme bmsSMaintainScheme = addBmsSMaintainSchemeParam.getBmsSMaintainScheme(); int id = idManagementService.getId("s_maintain_scheme"); bmsSMaintainScheme.setId(id); bmsSMaintainScheme.setDeleteState(0); bmsSMaintainSchemeMapper.insert(bmsSMaintainScheme); //关联关系表 List<BmsRMaintainScheme> bmsRMaintainSchemeList = addBmsSMaintainSchemeParam.getBmsSStructureList(); int bmsRMaintainSchemeId = idManagementService.getId("r_maintain_scheme", bmsRMaintainSchemeList.size()); for (BmsRMaintainScheme bmsRStructureStyle : bmsRMaintainSchemeList) { bmsRStructureStyle.setId(bmsRMaintainSchemeId++ - bmsRMaintainSchemeList.size() + 1); bmsRStructureStyle.setSchemeId(id); bmsRStructureStyle.setDeleteState(0); } bmsRMaintainSchemeService.saveBatch(bmsRMaintainSchemeList); }
List<String> lst = Arrays.asList("明奎","Dk","The 8","胜宽");
/** * 添加信息 * * @param request * @return */ @Override public BaseResponse add(AddAssetDataRequest request) { // 添加资产表信息 AmsDAssetData amsDAssetData = new AmsDAssetData(); int assetId = idManagementService.getId("ams_d_asset_data"); BeanUtils.copyProperties(request, amsDAssetData); amsDAssetData.setId(assetId); amsDAssetData.setDeleteState(0); //取当前时间 amsDAssetData.setCreateTime(new Date()); amsDAssetData.setModifyTime(new Date()); amsDAssetData.setModifyUserId(request.getCreateUserId()); amsDAssetData.setFacilityStatus(1); AmsDAssetData one = amsDAssetDataMapper.selectOne(new QueryWrapper<AmsDAssetData>().lambda().eq(AmsDAssetData::getFacilityCode, request.getFacilityCode()) .eq(AmsDAssetData::getDeleteState, 0)); if (one != null) { return new BaseResponse(ResponseEnum.ERROR.getCode(),"该设备已存在!"); } List<String> collect = securityDeviceMapper.selectList(new QueryWrapper<JcDSecurityDevice>() .lambda().eq(JcDSecurityDevice::getDeleteState, 0)) .stream().map(JcDSecurityDevice::getImei).collect(Collectors.toList()); if (StringUtils.isNotBlank(request.getAddress())) { amsDAssetData.setInstallAddr(request.getAddress()); JcDSecurityDevice selectOne = securityDeviceMapper.selectOne(new QueryWrapper<JcDSecurityDevice>() .lambda().eq(JcDSecurityDevice::getImei, request.getFacilityCode())); if (collect.contains(request.getFacilityCode())) { // 更新安装地址 selectOne.setInstallAddr(request.getAddress()); securityDeviceMapper.updateById(selectOne); } } int insert = amsDAssetDataMapper.insert(amsDAssetData); if (insert > 0) { // 添加资产附件信息 String attachFiles = request.getAttachFiles(); if (StringUtils.isNotBlank(attachFiles)) { List<String> strings = Arrays.asList(attachFiles.split(",")); addAttachFiles(strings, assetId, request.getShapeType().toString(), request.getAssetName(), request.getCreateUserId()); } return new BaseResponse(ResponseEnum.SUCCESS); } return new BaseResponse(ResponseEnum.ERROR.getCode(), "采集失败!"); }
@Override public List<BmsDMaintainHistoryUnit> getHisList(Integer msegmentId, String type, Integer year, Integer lastYear, List<Integer> unitIds) { MPJLambdaWrapper<BmsDMaintainHistoryUnit> objectMPJLambdaWrapper = new MPJLambdaWrapper<>(); // QueryWrapper<BmsDMaintainHistoryUnit> queryWrapper = new QueryWrapper<>(); objectMPJLambdaWrapper.selectAll(BmsDMaintainHistoryUnit.class).eq(BmsDMaintainHistoryUnit::getMsegmentId, msegmentId) .le(BmsDMaintainHistoryUnit::getYear, year) .eq(BmsDMaintainHistoryUnit::getYear, lastYear).eq(BmsDMaintainHistoryUnit::getDeleteState, 0); if (StringUtils.isNotBlank(type)) { objectMPJLambdaWrapper.like(BmsDMaintainHistoryUnit::getSchemeName, type); } if (CollectionUtils.isNotEmpty(unitIds)) { objectMPJLambdaWrapper.in(BmsDMaintainHistoryUnit::getUnitId, unitIds); } List<BmsDMaintainHistoryUnit> list = bmsDMaintainHistoryUnitMapper.selectJoinList(BmsDMaintainHistoryUnit.class, objectMPJLambdaWrapper); return list; }
@Override
public IPage<RmsDMsegmentResponse> selectPageList(GetMsegmentPageRequest rmsDMsegmentParam) {
if (CollectionUtils.isEmpty(rmsDMsegmentParam.getDeptIds())) {
rmsDMsegmentParam.setDeptIds(UserUtils.getDeptIds());
}
MPJLambdaWrapper mpjLambdaWrapper = selectLambdaWrapper(rmsDMsegmentParam);
return rmsDMsegmentMapper.selectJoinPage(new Page<>(rmsDMsegmentParam.getPageNum(), rmsDMsegmentParam.getPageSize()), RmsDMsegmentResponse.class, mpjLambdaWrapper);
}
@Override
public Map<String, List<MsegmentInfoResponse>> selectRouteByDept(GetMsegmentPageRequest rmsDMsegmentParam) {
MPJLambdaWrapper mpjLambdaWrapper = selectLambdaWrapper(rmsDMsegmentParam);
List<MsegmentInfoResponse> msegmentInfoResponseList = rmsDMsegmentMapper.selectJoinList(MsegmentInfoResponse.class, mpjLambdaWrapper);
Map<String, List<MsegmentInfoResponse>> listMap = msegmentInfoResponseList.stream().collect(Collectors.groupingBy(MsegmentInfoResponse::getDeptName));
return listMap;
}
@Data @TableName("ria_d_project_scheme") @ApiModel(value = "RiaDProjectScheme对象", description = "项目库维修方案表") public class RiaDProjectScheme implements Serializable { private static final long serialVersionUID = 1L; @ApiModelProperty(value = "主键") @TableId(value = "id", type = IdType.INPUT) private Integer id; //关联查询出deptName存放在实体 @ApiModelProperty(value = "单位名称") @TableField(exist = false) private String deptName; @ApiModelProperty(value = "指定国检车道pqi") private Double nationalPqi; }
List<RiaSUnitAnalysis> lstUnit = unitAnalysisMapper.selectList(new QueryWrapper<RiaSUnitAnalysis>().lambda()
.eq(RiaSUnitAnalysis::getYear, year)
.in(RiaSUnitAnalysis::getUnitId, unitIds));
calDiffParam.lstPQI = Arrays.asList(100.0);
Double prior = 0.0;
boolean flag = prior.equals(Double.NaN); //prior = NaN 时,判断结果为真
prior == null || prior.equals(null) <------起不到判断作用
String a = "test1";
if(!a.equals("test1"));
注:StringUtils 和 StringUtil 判空
方法\工具类 | StringUtils | StringUtil |
---|---|---|
.isEmpty() | 成立 | 成立 |
.isNotEmpty() | 成立 | 不成立 |
.isBlank() | 成立 | 不成立 |
String scheme = "";
boolean flag = StringUtils.isBlank(this.scheme);
flag = StringUtils.isNotEmpty(this.scheme);
flag = StringUtils.isEmpty(this.scheme);
if (m_lstGeneralParam == null || m_lstGeneralParam.size() <= 0) {
return;
}
AmsDAssetData one = amsDAssetDataMapper.selectOne(new QueryWrapper<AmsDAssetData>().lambda().
.eq(AmsDAssetData::getDeleteState, 0));
if (one != null) {
return new BaseResponse(ResponseEnum.ERROR.getCode(),"该设备已存在!");
}
response.getLstBeforeRepair().forEach(param -> param.setMsegmentName(lstMsegment.get(0).getMsegmentName()));
//从小到大:
lstKM.sort((a, b) -> {
Double d1 = a.getPQI();
Double d2 = b.getPQI();
return d1.compareTo(d2);
});
//从大到小:
lstKM.sort((a, b) -> {
Double d1 = a.getPQI();
Double d2 = b.getPQI();
return d2.compareTo(d1);
});
if (CollectionUtils.isEmpty(lstPQI)) {
throw new BusinessException(ResponseEnum.ERROR.getCode(), "PQI不能为空");
}
if (one != null) {
return new BaseResponse(ResponseEnum.ERROR.getCode(),"该设备已存在!");
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。