diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseTaskMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseTaskMapper.java index 35a32120..9030299f 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseTaskMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseTaskMapper.java @@ -291,4 +291,11 @@ public interface LeaseTaskMapper { * @return */ int updateLeaseOutNumNew(LeaseApplyDetails leaseApplyDetails); + + /** + * 领用申请详情修改 -- 减少领用数量 + * @param bean + * @return + */ + int insertBackRecordByMaId(LeaseApplyDetails bean); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java index 685978a9..287939cd 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java @@ -55,6 +55,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.web.util.UriComponentsBuilder; import javax.annotation.Resource; +import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -1205,14 +1206,51 @@ public class LeaseTaskServiceImpl implements ILeaseTaskService { if (res == GlobalConstants.INT_0) { throw new RuntimeException("出库失败,插入结算记录失败"); } - return AjaxResult.success("领用出库驳回成功"); + + //增加退回记录 + insertBackRecord(leaseApplyDetails); + return AjaxResult.success("领用出库退回成功"); } catch (Exception e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - log.error("领用出库驳回失败:",e.getMessage()); - return AjaxResult.error("领用出库驳回失败"); + log.error("领用出库退回失败:",e.getMessage()); + return AjaxResult.error("领用出库退回失败"); } } + /** + * 添加退回记录 + * @param leaseApplyDetails + */ + public void insertBackRecord(LeaseApplyDetails leaseApplyDetails) { + // 查询当前登陆用户信息 + Long theLoginUserId = SecurityUtils.getLoginUser().getSysUser().getUserId(); + LeaseApplyDetails bean = new LeaseApplyDetails(); + //判断是编码还是数量 + if (leaseApplyDetails.getMaCodeVoList()!=null){ + //编码 + for (MaCodeVo maCodeVo : leaseApplyDetails.getMaCodeVoList()) { + //添加退回记录 + bean.setMaId(maCodeVo.getMaId()); + bean.setParentId(leaseApplyDetails.getParentId()); + bean.setTypeId(leaseApplyDetails.getTypeId()); + bean.setNewTypeId(leaseApplyDetails.getNewTypeId()); + bean.setNum(BigDecimal.valueOf(1)); + bean.setCreateBy(String.valueOf(theLoginUserId)); + int res = mapper.insertBackRecordByMaId(bean); + } + } else { + //数量 + bean.setParentId(leaseApplyDetails.getParentId()); + bean.setTypeId(leaseApplyDetails.getTypeId()); + bean.setNewTypeId(leaseApplyDetails.getNewTypeId()); + bean.setNum(leaseApplyDetails.getAlNum()); + bean.setCreateBy(String.valueOf(theLoginUserId)); + bean.setNum(leaseApplyDetails.getNum()); + int res = mapper.insertBackRecordByMaId(bean); + } + + } + /** * 删除结算记录 * @param leaseApplyDetails diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseTaskMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseTaskMapper.xml index 112fcaf2..73ba2e0f 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseTaskMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseTaskMapper.xml @@ -969,6 +969,27 @@ #{isExamine}, + + insert into lease_back_record + + parent_id, + type_id, + new_type, + ma_id, + num, + create_by, + create_time, + + + #{parentId}, + #{typeId}, + #{newTypeId}, + #{maId}, + #{num}, + #{createBy}, + now(), + +