package org.jeecg.modules.tms.service.impl; import org.apache.commons.beanutils.BeanUtils; import org.jeecg.modules.tms.entity.TmsToolInbound; import org.jeecg.modules.tms.entity.TmsToolInboundDetail; import org.jeecg.modules.tms.mapper.TmsToolInboundDetailMapper; import org.jeecg.modules.tms.mapper.TmsToolInboundMapper; import org.jeecg.modules.tms.service.ITmsToolInboundDetailService; import org.jeecg.modules.tms.service.ITmsToolInboundService; import org.jeecg.modules.tms.vo.TmsToolInboundRequest; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import java.io.Serializable; import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.Collection; /** * @Description: 工装入库 * @Author: jeecg-boot * @Date: 2025-07-28 * @Version: V1.0 */ @Service public class TmsToolInboundServiceImpl extends ServiceImpl implements ITmsToolInboundService { @Autowired private TmsToolInboundMapper tmsToolInboundMapper; @Autowired private TmsToolInboundDetailMapper tmsToolInboundDetailMapper; @Autowired private ITmsToolInboundDetailService tmsToolInboundDetailService; @Override @Transactional(rollbackFor = Exception.class) public void delMain(String id) { tmsToolInboundDetailMapper.deleteByMainId(id); tmsToolInboundMapper.deleteById(id); } @Override @Transactional(rollbackFor = Exception.class) public void delBatchMain(Collection idList) { for(Serializable id:idList) { tmsToolInboundDetailMapper.deleteByMainId(id.toString()); tmsToolInboundMapper.deleteById(id); } } @Override @Transactional(rollbackFor = Exception.class) public void add(TmsToolInboundRequest tmsToolInboundRequest) throws InvocationTargetException, IllegalAccessException { TmsToolInbound tmsToolInbound = new TmsToolInbound(); BeanUtils.copyProperties(tmsToolInbound, tmsToolInboundRequest); save(tmsToolInbound); List tmsToolInboundDetailList = tmsToolInboundRequest.getTmsToolInboundDetailList(); tmsToolInboundDetailList.forEach(tmsToolInboundDetail -> { tmsToolInboundDetail.setId(null); tmsToolInboundDetail.setOrderId(tmsToolInbound.getId()); }); tmsToolInboundDetailService.saveBatch(tmsToolInboundDetailList); } @Override @Transactional(rollbackFor = Exception.class) public void update(TmsToolInboundRequest tmsToolInboundRequest) throws InvocationTargetException, IllegalAccessException { tmsToolInboundDetailMapper.deleteByMainId(tmsToolInboundRequest.getId()); TmsToolInbound toolInboundUpdate = new TmsToolInbound(); BeanUtils.copyProperties(toolInboundUpdate, tmsToolInboundRequest); updateById(toolInboundUpdate); List tmsToolInboundDetailList = tmsToolInboundRequest.getTmsToolInboundDetailList(); tmsToolInboundDetailList.forEach(tmsToolInboundDetail -> { tmsToolInboundDetail.setId(null); tmsToolInboundDetail.setOrderId(tmsToolInboundRequest.getId()); }); tmsToolInboundDetailService.saveBatch(tmsToolInboundDetailList); } }