| | |
| | | package com.vincent.rsf.server.manager.service.impl; |
| | | |
| | | import com.vincent.rsf.server.manager.controller.params.ReviseLogParams; |
| | | import com.vincent.rsf.server.manager.entity.LocRevise; |
| | | import com.vincent.rsf.server.manager.entity.ReviseLogItem; |
| | | import com.vincent.rsf.server.manager.mapper.ReviseLogMapper; |
| | | import com.vincent.rsf.server.manager.entity.ReviseLog; |
| | | import com.vincent.rsf.server.manager.service.LocReviseService; |
| | | import com.vincent.rsf.server.manager.service.ReviseLogService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | @Service("reviseLogService") |
| | | public class ReviseLogServiceImpl extends ServiceImpl<ReviseLogMapper, ReviseLog> implements ReviseLogService { |
| | | |
| | | @Autowired |
| | | private LocReviseService locReviseService; |
| | | |
| | | @Autowired |
| | | private ReviseLogService reviseLogService; |
| | | |
| | | /** |
| | | * 库存调整单明细添加 |
| | | * @param revise |
| | | * @param loginUserId |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public List<ReviseLog> reviseLoc(ReviseLogParams revise, Long loginUserId) { |
| | | LocRevise locRevise = locReviseService.getById(revise.getReviseId()); |
| | | if (Objects.isNull(locRevise)) { |
| | | throw new RuntimeException("调整单据不存在!!"); |
| | | } |
| | | List<ReviseLog> items = revise.getItems(); |
| | | if (items.isEmpty()) { |
| | | throw new RuntimeException("调整单明细参数为空!!"); |
| | | } |
| | | items.forEach(item -> { |
| | | ReviseLog reviseLog = new ReviseLog(); |
| | | BeanUtils.copyProperties(item, reviseLog); |
| | | reviseLog.setAreaId(locRevise.getAreaId()) |
| | | .setReviseId(locRevise.getId()) |
| | | .setCreateBy(loginUserId) |
| | | .setUpdateBy(loginUserId) |
| | | .setReviseCode(locRevise.getCode()) ; |
| | | if (!reviseLogService.save(reviseLog)) { |
| | | throw new RuntimeException("调整单明细保存失败!!"); |
| | | } |
| | | }); |
| | | return items; |
| | | } |
| | | } |