| | |
| | | package com.ruoyi.measuringinstrumentledger.service.impl; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.device.mapper.DeviceLedgerMapper; |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | | import com.ruoyi.measuringinstrumentledger.dto.SparePartsDto; |
| | | import com.ruoyi.measuringinstrumentledger.mapper.SparePartsMapper; |
| | | import com.ruoyi.measuringinstrumentledger.pojo.SpareParts; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class SparePartsServiceImpl extends ServiceImpl<SparePartsMapper, SpareParts> implements SparePartsService { |
| | | @Autowired |
| | | private SparePartsMapper sparePartsMapper; |
| | | |
| | | @Autowired |
| | | private DeviceLedgerMapper deviceLedgerMapper; |
| | | |
| | | @Override |
| | | public IPage<SparePartsDto> listPage(Page page, SpareParts spareParts) { |
| | | return sparePartsMapper.listPage(page,spareParts); |
| | | IPage<SparePartsDto> sparePartsDtoIPage = sparePartsMapper.listPage(page, spareParts); |
| | | for (SparePartsDto record : sparePartsDtoIPage.getRecords()) { |
| | | if(StringUtils.isNotEmpty(record.getDeviceIds())){ |
| | | List<String> deviceIds = StringUtils.str2List(record.getDeviceIds(), ",", true, true); |
| | | List<DeviceLedger> deviceLedgers = deviceLedgerMapper.selectBatchIds(deviceIds); |
| | | if(CollectionUtils.isNotEmpty(deviceLedgers)){ |
| | | record.setDeviceNameStr(deviceLedgers.stream().map(DeviceLedger::getDeviceName).collect(Collectors.joining( ","))); |
| | | } |
| | | } |
| | | } |
| | | return sparePartsDtoIPage; |
| | | } |
| | | |
| | | @Override |