| | |
| | | package com.by4cloud.platformx.device.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.by4cloud.platformx.device.dto.ReceivingNoteQueryDTO; |
| | | import com.by4cloud.platformx.device.entity.DeviceInventory; |
| | | import com.by4cloud.platformx.device.entity.ReceivingNote; |
| | | import com.by4cloud.platformx.device.entity.ReceivingNoteItem; |
| | | import com.by4cloud.platformx.device.mapper.DeviceInventoryMapper; |
| | | import com.by4cloud.platformx.device.mapper.ReceivingNoteItemMapper; |
| | | import com.by4cloud.platformx.device.mapper.ReceivingNoteMapper; |
| | | import com.by4cloud.platformx.device.service.ReceivingNoteService; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 验收表 |
| | | * |
| | |
| | | * @date 2025-03-13 11:03:52 |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class ReceivingNoteServiceImpl extends ServiceImpl<ReceivingNoteMapper, ReceivingNote> implements ReceivingNoteService { |
| | | |
| | | private final ReceivingNoteItemMapper itemMapper; |
| | | private final DeviceInventoryMapper inventoryMapper; |
| | | |
| | | @Override |
| | | public IPage pageNew(Page page, ReceivingNoteQueryDTO queryDTO) { |
| | | return baseMapper.pageNew(page,queryDTO); |
| | | } |
| | | |
| | | @Override |
| | | public boolean saveDeep(ReceivingNote entity) { |
| | | baseMapper.insert(entity); |
| | | if (entity.getNoteItemList()!=null&&entity.getNoteItemList().size()>0){ |
| | | for (ReceivingNoteItem item:entity.getNoteItemList() |
| | | ) { |
| | | item.setNoteId(entity.getId()); |
| | | itemMapper.insert(item); |
| | | //设备库存同步新增 |
| | | if (item.getSerialNos()!=null&&item.getSerialNos().size()>0){ |
| | | for (String serialNo:item.getSerialNos() |
| | | ) { |
| | | DeviceInventory inventory = new DeviceInventory(); |
| | | inventory.setDeviceId(item.getDeviceId()); |
| | | inventory.setDeviceNumber(item.getDeviceCode()); |
| | | inventory.setName(item.getDeviceName()); |
| | | inventory.setSerialNo(serialNo); |
| | | inventory.setSource(1); |
| | | inventoryMapper.insert(inventory); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | @Override |
| | | public boolean updateByIdDeep(ReceivingNote entity) { |
| | | baseMapper.updateById(entity); |
| | | QueryWrapper<ReceivingNoteItem> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("note_id",entity.getId()); |
| | | itemMapper.delete(queryWrapper); |
| | | if (entity.getNoteItemList()!=null&&entity.getNoteItemList().size()>0){ |
| | | for (ReceivingNoteItem item:entity.getNoteItemList() |
| | | ) { |
| | | item.setNoteId(entity.getId()); |
| | | itemMapper.insert(item); |
| | | } |
| | | } |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | @Override |
| | | public ReceivingNote getByIdDeep(Long id) { |
| | | ReceivingNote note = baseMapper.selectById(id); |
| | | QueryWrapper<ReceivingNoteItem> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("note_id",note.getId()); |
| | | List<ReceivingNoteItem> itemList = itemMapper.selectList(queryWrapper); |
| | | note.setNoteItemList(itemList); |
| | | return note; |
| | | } |
| | | } |