From 129550fa1365a7ca67b33d11d6c650a2e70e7bd5 Mon Sep 17 00:00:00 2001 From: mashuai Date: Mon, 13 Jan 2025 18:03:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/LeaseApplyInfoController.java | 43 +++++++++ .../lease/domain/LeaseApplyDetails.java | 6 ++ .../lease/mapper/LeaseApplyDetailsMapper.java | 21 +++++ .../lease/mapper/LeaseOutDetailsMapper.java | 7 ++ .../lease/service/ILeaseApplyInfoService.java | 23 +++++ .../service/ILeaseOutDetailsService.java | 6 ++ .../impl/LeaseApplyInfoServiceImpl.java | 30 +++++++ .../impl/LeaseOutDetailsServiceImpl.java | 87 ++++++++++++++++++- .../bonus/material/ma/mapper/TypeMapper.java | 7 ++ .../mapper/SltAgreementInfoMapper.java | 7 ++ .../mapper/material/basic/BmQrBoxMapper.xml | 2 +- .../lease/LeaseApplyDetailsMapper.xml | 78 +++++++++++++++++ .../material/lease/LeaseOutDetailsMapper.xml | 6 ++ .../mapper/material/ma/TypeMapper.xml | 9 ++ .../settlement/SltAgreementInfoMapper.xml | 10 +++ 15 files changed, 337 insertions(+), 5 deletions(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseApplyInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseApplyInfoController.java index ba06290d..c031c4ee 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseApplyInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseApplyInfoController.java @@ -1,6 +1,7 @@ package com.bonus.material.lease.controller; import com.bonus.common.biz.annotation.StoreLog; +import com.bonus.common.biz.domain.lease.LeaseOutDetails; import com.bonus.common.core.utils.poi.ExcelUtil; import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.domain.AjaxResult; @@ -73,6 +74,32 @@ public class LeaseApplyInfoController extends BaseController { return success(leaseApplyInfoService.selectLeaseApplyInfoById(id, keyWord)); } + /** + * 获取领料出库内部详细信息 + * @param leaseApplyDetails + * @return + */ + @ApiOperation(value = "获取领料出库内部详细信息") + //@RequiresPermissions("lease:info:query") + @GetMapping(value = "/getInnerById") + public AjaxResult getInnerById(LeaseApplyDetails leaseApplyDetails) { + return success(leaseApplyInfoService.getInnerById(leaseApplyDetails)); + } + + /** + * 获取领料出库内部详细信息 + * @param leaseApplyDetails + * @return + */ + @ApiOperation(value = "获取领料出库内部详细信息") + //@RequiresPermissions("lease:info:query") + @GetMapping(value = "/getDetailsById") + public AjaxResult getDetailsById(LeaseApplyDetails leaseApplyDetails) { + startPage(); + List list = leaseApplyInfoService.getDetailsById(leaseApplyDetails); + return AjaxResult.success(getDataTable(list)); + } + /** * 获取领料出库单详细信息 * @param leaseApplyInfo @@ -207,6 +234,22 @@ public class LeaseApplyInfoController extends BaseController { } } + /** + * app领料出库退回 + * @param leaseOutDetails + * @return + */ + @ApiOperation(value = "app领料出库退回") + @PreventRepeatSubmit + @PostMapping("/leaseOutBack") + public AjaxResult leaseOutBack(@NotNull(message = "领料出库信息不能为空") @RequestBody LeaseOutDetails leaseOutDetails) { + try { + return leaseApplyInfoService.leaseOutBack(leaseOutDetails); + } catch (Exception e) { + return error("系统错误, " + e.getMessage()); + } + } + /** * 删除领料任务 */ diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyDetails.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyDetails.java index aade8173..52378dcd 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyDetails.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyDetails.java @@ -38,11 +38,17 @@ public class LeaseApplyDetails extends BaseEntity { @ApiModelProperty(value = "规格型号id") private Long typeId; + @ApiModelProperty(value = "规格型号id") + private Long taskId; + /** 规格型号 */ @ApiModelProperty(value = "规格型号名称") @Excel(name = "规格型号") private String typeName; + @ApiModelProperty(value = "机具编码") + private String maCode; + /** 计量单位 */ @ApiModelProperty(value = "计量单位") @Excel(name = "计量单位") diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseApplyDetailsMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseApplyDetailsMapper.java index 562accbf..4c593eb7 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseApplyDetailsMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseApplyDetailsMapper.java @@ -105,4 +105,25 @@ public interface LeaseApplyDetailsMapper { * @return */ List selectLeaseOutDetailsList(@Param("id") Long id, @Param("userId") Long userId); + + /** + * 根据领料任务id查询领料任务详细 + * @param leaseApplyDetails + * @return + */ + LeaseApplyDetails getInnerById(LeaseApplyDetails leaseApplyDetails); + + /** + * 根据领料任务id查询领料任务详细 + * @param leaseApplyDetails + * @return + */ + List getDetailsById(LeaseApplyDetails leaseApplyDetails); + + /** + * 领料退回 + * @param leaseOutDetails + * @return + */ + int updateBackDetailsOutNum(LeaseOutDetails leaseOutDetails); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseOutDetailsMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseOutDetailsMapper.java index ec9c0b3f..865a1096 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseOutDetailsMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseOutDetailsMapper.java @@ -81,4 +81,11 @@ public interface LeaseOutDetailsMapper { * @return */ Type selectByTypeId(LeaseOutDetails record); + + /** + * 根据任务id删除领料出库详细 + * @param leaseOutDetails + * @return + */ + int deleteLeaseOutDetails(LeaseOutDetails leaseOutDetails); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseApplyInfoService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseApplyInfoService.java index 0b221aa9..cca49010 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseApplyInfoService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseApplyInfoService.java @@ -1,6 +1,8 @@ package com.bonus.material.lease.service; import java.util.List; + +import com.bonus.common.biz.domain.lease.LeaseOutDetails; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.biz.domain.lease.LeaseApplyInfo; import com.bonus.material.basic.domain.BmQrcodeInfo; @@ -112,4 +114,25 @@ public interface ILeaseApplyInfoService { * @param response */ void exportInfo(LeaseApplyRequestVo leaseApplyRequestVo, HttpServletResponse response); + + /** + * 根据id查询内部领料任务详情 + * @param leaseApplyDetails + * @return + */ + LeaseApplyDetails getInnerById(LeaseApplyDetails leaseApplyDetails); + + /** + * 根据id查询领料任务详情 + * @param leaseApplyDetails + * @return + */ + List getDetailsById(LeaseApplyDetails leaseApplyDetails); + + /** + * 领料任务出库回退 + * @param leaseOutDetails + * @return + */ + AjaxResult leaseOutBack(LeaseOutDetails leaseOutDetails); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseOutDetailsService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseOutDetailsService.java index d0a425e3..97e9924f 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseOutDetailsService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseOutDetailsService.java @@ -62,4 +62,10 @@ public interface ILeaseOutDetailsService { public AjaxResult leaseOut(LeaseOutDetails record); + /** + * app领料出库退回 + * @param leaseOutDetails + * @return + */ + AjaxResult leaseOutBack(LeaseOutDetails leaseOutDetails); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java index c23de61a..64e66b02 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java @@ -401,6 +401,36 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { } } + /** + * 领料单详情 + * @param leaseApplyDetails + * @return + */ + @Override + public LeaseApplyDetails getInnerById(LeaseApplyDetails leaseApplyDetails) { + return leaseApplyDetailsMapper.getInnerById(leaseApplyDetails); + } + + /** + * 领料单详情 + * @param leaseApplyDetails + * @return + */ + @Override + public List getDetailsById(LeaseApplyDetails leaseApplyDetails) { + return leaseApplyDetailsMapper.getDetailsById(leaseApplyDetails); + } + + /** + * app领料出库退回 + * @param leaseOutDetails + * @return + */ + @Override + public AjaxResult leaseOutBack(LeaseOutDetails leaseOutDetails) { + return leaseOutDetailsService.leaseOutBack(leaseOutDetails); + } + /** * 导出领料单 * @param response diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java index e66d3e85..7c83234e 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java @@ -23,6 +23,7 @@ import com.bonus.material.ma.mapper.MachineMapper; import com.bonus.material.ma.mapper.TypeMapper; import com.bonus.material.settlement.domain.SltAgreementInfo; import com.bonus.material.settlement.mapper.SltAgreementInfoMapper; +import com.bonus.material.task.domain.TmTask; import com.bonus.material.task.mapper.TmTaskAgreementMapper; import com.bonus.material.task.mapper.TmTaskMapper; import lombok.extern.slf4j.Slf4j; @@ -189,13 +190,13 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService { if (res == 0) { throw new RuntimeException("出库失败,插入结算记录失败"); } - /*if (record.getManageType().equals(InputOutEnum.STANDARD_BOX.getTypeId())) { - // 6、如果标准箱入库,需要将设备从标准箱移出 + // 6、如果标准箱入库,需要将设备从标准箱移出 + if (record.getMaId() != null) { res = updateBoxBind(record); if (res == 0) { throw new RuntimeException("出库失败,移出设备失败"); } - }*/ + } } else { return AjaxResult.error("领料出库失败,机具库存不足"); } @@ -209,8 +210,86 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService { return AjaxResult.success("出库成功"); } + /** + * app领料出库退回 + * + * @param leaseOutDetails + * @return + */ + @Override + public AjaxResult leaseOutBack(LeaseOutDetails leaseOutDetails) { + int res = 0; + try { + // 1 根据任务id查询此任务是否已经完结 + TmTask tmTask = tmTaskMapper.selectTmTaskByTaskId(Long.valueOf(leaseOutDetails.getTaskId())); + if (tmTask != null && tmTask.getTaskStatus().equals(LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatus())) { + return AjaxResult.error("该任务已完成,不能进行退库操作"); + } + // 3、插入出库记录,修改库存,修改机具状态 + res = updateRecords(leaseOutDetails); + if (res == 0) { + throw new RuntimeException("出库退回失败,更新设备规格库存数量时出错!"); + } + // 4、修改任务状态(tm_task) + res = editTaskStatus(leaseOutDetails); + if (res == 0) { + throw new RuntimeException("出库退回失败,修改任务状态失败"); + } + // 5、删除结算记录 + res = deleteSltInfo(leaseOutDetails); + if (res == 0) { + throw new RuntimeException("出库失败,插入结算记录失败"); + } + } catch (RuntimeException re) { + return AjaxResult.error("出库退回失败"); + } + return AjaxResult.success("出库退回成功"); + } + + /** + * 删除结算记录 + * @param leaseOutDetails + * @return + */ + private int deleteSltInfo(LeaseOutDetails leaseOutDetails) { + return sltAgreementInfoMapper.deleteSltInfo(leaseOutDetails); + } + + /** + * 修改任务状态(tm_task) + * @param leaseOutDetails + * @return + */ + private int editTaskStatus(LeaseOutDetails leaseOutDetails) { + return tmTaskMapper.updateTaskStatus(leaseOutDetails.getTaskId(), LeaseTaskStatusEnum.LEASE_TASK_IN_PROGRESS.getStatus()); + } + + /** + * 更新出库记录 + * @param leaseOutDetails + * @return + */ + private int updateRecords(LeaseOutDetails leaseOutDetails) { + int res = 0; + // 首先更新领料任务详情表的领料数及状态(lease_apply_details) + leaseOutDetails.setUpdateBy(SecurityUtils.getUsername()); + res = leaseApplyDetailsMapper.updateBackDetailsOutNum(leaseOutDetails); + if (res > 0) { + // 删除领料出库明细表(lease_out_details) + res = leaseOutDetailsMapper.deleteLeaseOutDetails(leaseOutDetails); + if (res > 0) { + // 普通机具减少 (ma_type 设备规格表)的库存数量 + res = typeMapper.addMaTypeStockNum(leaseOutDetails); + // 更新 (ma_machine 设备表)的状态 + machineMapper.updateMaMachineStatus(leaseOutDetails, MaMachineStatusEnum.IN_STORE.getStatus()); + } + } + return res; + } + /** * 标准箱移出设备 + * * @param record * @return */ @@ -284,7 +363,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService { return 0; } - if (record.getOutNum() == null ) { + if (record.getOutNum() == null) { record.setOutNum(BigDecimal.valueOf(0L)); } //判断(ma_type 设备规格表)中的库存够不够出库的 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java index 88061c19..d1c698f8 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java @@ -158,4 +158,11 @@ public interface TypeMapper { int deleteTypeRepairerByTypeId(Type type); int insertTypeRepairer(Type repairer); + + /** + * 库存退回 + * @param leaseOutDetails + * @return + */ + int addMaTypeStockNum(@Param("record") LeaseOutDetails leaseOutDetails); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/mapper/SltAgreementInfoMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/mapper/SltAgreementInfoMapper.java index 1df2fd1b..a0b84d0d 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/mapper/SltAgreementInfoMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/mapper/SltAgreementInfoMapper.java @@ -97,4 +97,11 @@ public interface SltAgreementInfoMapper { * 退料驳回结算信息处理 */ int backRejectSltCope(Long backTaskId); + + /** + * 退料结算信息删除 + * @param leaseOutDetails + * @return + */ + int deleteSltInfo(@Param("record") LeaseOutDetails leaseOutDetails); } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/BmQrBoxMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/BmQrBoxMapper.xml index 92285c56..c687f5f6 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/BmQrBoxMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/BmQrBoxMapper.xml @@ -147,7 +147,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from bm_qrcode_box_bind where box_id = #{boxId} and ma_id = #{maId} + delete from bm_qrcode_box_bind where ma_id = #{maId} diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml index adc9386e..22b3d207 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml @@ -212,6 +212,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" parent_id = #{record.parentId} and type_id = #{record.typeId} + + UPDATE + lease_apply_details + SET + al_num = al_num - #{outNum}, + + update_by = #{updateBy}, + + update_time = now(), + status = '1' + WHERE + parent_id = #{parentId} and type_id = #{typeId} + + + + + + diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml index 4139569f..9973a0c6 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml @@ -176,5 +176,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{id} + + delete from lease_out_details where parent_id = #{parentId} and type_id = #{typeId} + + and ma_id = #{maId} + + \ No newline at end of file diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml index 534bcd23..b213f2fd 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml @@ -813,5 +813,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" insert into ma_type_repair(type_id, user_id) values (#{typeId},#{repairerId}) + + UPDATE + ma_type + SET + storage_num = storage_num + #{record.outNum} ,update_time = NOW() + WHERE + type_id = #{record.typeId} + + diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml index f21d808c..7972c8b8 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml @@ -136,6 +136,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + DELETE FROM slt_agreement_info + WHERE + lease_id = #{record.parentId} + and type_id = #{record.typeId} + + AND ma_id = #{record.maId} + + +