From 89ffb9fded4da0fbac9a14d4979aa7623b0a78f0 Mon Sep 17 00:00:00 2001 From: cuilei <ray_tsu1@163.com> Date: 星期一, 28 七月 2025 20:47:00 +0800 Subject: [PATCH] 工装管理基础代码 --- src/main/java/org/jeecg/modules/tms/service/impl/TmsToolInboundServiceImpl.java | 81 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 81 insertions(+), 0 deletions(-) diff --git a/src/main/java/org/jeecg/modules/tms/service/impl/TmsToolInboundServiceImpl.java b/src/main/java/org/jeecg/modules/tms/service/impl/TmsToolInboundServiceImpl.java new file mode 100644 index 0000000..af87174 --- /dev/null +++ b/src/main/java/org/jeecg/modules/tms/service/impl/TmsToolInboundServiceImpl.java @@ -0,0 +1,81 @@ +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<TmsToolInboundMapper, TmsToolInbound> 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<? extends Serializable> 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<TmsToolInboundDetail> 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<TmsToolInboundDetail> tmsToolInboundDetailList = tmsToolInboundRequest.getTmsToolInboundDetailList(); + tmsToolInboundDetailList.forEach(tmsToolInboundDetail -> { + tmsToolInboundDetail.setId(null); + tmsToolInboundDetail.setOrderId(tmsToolInboundRequest.getId()); + }); + tmsToolInboundDetailService.saveBatch(tmsToolInboundDetailList); + } + +} -- Gitblit v1.9.3