From e5fac4752650c6f79701d77a2daa5cd90ce4e477 Mon Sep 17 00:00:00 2001 From: Administrator <1923636941@qq.com> Date: Sat, 27 May 2023 11:57:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=BA=E5=85=A5=E5=BA=93=E7=9A=84=E8=84=8F?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...alPointCheckIntoWarehouseDetailMapper.java | 7 ++ ...ialPointCheckIntoWarehouseDetailMapper.xml | 7 ++ .../GtMaterialInOutWarehouseServiceImpl.java | 110 ++++++++++++++++-- 3 files changed, 114 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/zhgd/xmgl/modules/gt/mapper/GtMaterialPointCheckIntoWarehouseDetailMapper.java b/src/main/java/com/zhgd/xmgl/modules/gt/mapper/GtMaterialPointCheckIntoWarehouseDetailMapper.java index 1c9bac649..b8ec23442 100644 --- a/src/main/java/com/zhgd/xmgl/modules/gt/mapper/GtMaterialPointCheckIntoWarehouseDetailMapper.java +++ b/src/main/java/com/zhgd/xmgl/modules/gt/mapper/GtMaterialPointCheckIntoWarehouseDetailMapper.java @@ -1,8 +1,14 @@ package com.zhgd.xmgl.modules.gt.mapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.toolkit.Constants; import com.zhgd.xmgl.modules.gt.entity.GtMaterialPointCheckIntoWarehouseDetail; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * @Description: 出入库的物料详情 @@ -13,4 +19,5 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface GtMaterialPointCheckIntoWarehouseDetailMapper extends BaseMapper { + List getCheckIntoWarehouseDetails(List typeList, @Param(Constants.WRAPPER) QueryWrapper uniqueIntoWarehouseDetailQueryWrapper); } diff --git a/src/main/java/com/zhgd/xmgl/modules/gt/mapper/xml/GtMaterialPointCheckIntoWarehouseDetailMapper.xml b/src/main/java/com/zhgd/xmgl/modules/gt/mapper/xml/GtMaterialPointCheckIntoWarehouseDetailMapper.xml index 57f0fbd78..93b1eef47 100644 --- a/src/main/java/com/zhgd/xmgl/modules/gt/mapper/xml/GtMaterialPointCheckIntoWarehouseDetailMapper.xml +++ b/src/main/java/com/zhgd/xmgl/modules/gt/mapper/xml/GtMaterialPointCheckIntoWarehouseDetailMapper.xml @@ -1,4 +1,11 @@ + diff --git a/src/main/java/com/zhgd/xmgl/modules/gt/service/impl/GtMaterialInOutWarehouseServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/gt/service/impl/GtMaterialInOutWarehouseServiceImpl.java index eb5f7dbfa..52a3efc70 100644 --- a/src/main/java/com/zhgd/xmgl/modules/gt/service/impl/GtMaterialInOutWarehouseServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/gt/service/impl/GtMaterialInOutWarehouseServiceImpl.java @@ -14,6 +14,7 @@ import com.zhgd.xmgl.modules.gt.entity.GtMaterialInOutWarehouse; import com.zhgd.xmgl.modules.gt.entity.GtMaterialPointCheckIntoWarehouseDetail; import com.zhgd.xmgl.modules.gt.entity.GtMaterialWarehouseDetail; import com.zhgd.xmgl.modules.gt.mapper.GtMaterialInOutWarehouseMapper; +import com.zhgd.xmgl.modules.gt.mapper.GtMaterialPointCheckIntoWarehouseDetailMapper; import com.zhgd.xmgl.modules.gt.mapper.GtMaterialWarehouseDetailMapper; import com.zhgd.xmgl.modules.gt.service.IGtMaterialInOutWarehouseService; import com.zhgd.xmgl.modules.gt.service.IGtMaterialPointCheckIntoWarehouseDetailService; @@ -25,6 +26,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletRequest; +import java.util.Arrays; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -39,6 +41,8 @@ import java.util.stream.Collectors; @Slf4j @Transactional(rollbackFor = Exception.class) public class GtMaterialInOutWarehouseServiceImpl extends ServiceImpl implements IGtMaterialInOutWarehouseService { + @Autowired + private GtMaterialPointCheckIntoWarehouseDetailMapper gtMaterialPointCheckIntoWarehouseDetailMapper; @Autowired IGtMaterialPointCheckIntoWarehouseDetailService materialPointCheckIntoWarehouseDetailService; @Autowired @@ -79,9 +83,16 @@ public class GtMaterialInOutWarehouseServiceImpl extends ServiceImpl materialList = gtMaterialInOutWarehouse.getMaterialList(); + if (Objects.equals(gtMaterialInOutWarehouse.getType(), 20)) { + //出库 + useStock(materialList); + } else if (Objects.equals(gtMaterialInOutWarehouse.getType(), 15)) { + //退库 + materialList = getReverseGtMaterialPointCheckIntoWarehouseDetails(materialList); + useStock(materialList); + } } result.success("添加成功!"); } catch (Exception e) { @@ -136,7 +147,40 @@ public class GtMaterialInOutWarehouseServiceImpl extends ServiceImpl getUniqueIntoWarehouseDetailLambdaQueryWrapper(GtMaterialPointCheckIntoWarehouseDetail one) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(GtMaterialPointCheckIntoWarehouseDetail::getName, one.getName()) + .eq(GtMaterialPointCheckIntoWarehouseDetail::getUnit, one.getUnit()) + .eq(GtMaterialPointCheckIntoWarehouseDetail::getSpecification, one.getSpecification()) + .eq(GtMaterialPointCheckIntoWarehouseDetail::getUnitPrice, one.getUnitPrice()) + .eq(GtMaterialPointCheckIntoWarehouseDetail::getProjectSn, one.getProjectSn()); + return queryWrapper; + } + + /** + * 获取确定唯一库存的出入库详情的物料的品名的查询,添加别名 + * + * @param one + * @return + */ + private QueryWrapper getUniqueIntoWarehouseDetailQueryWrapper(GtMaterialPointCheckIntoWarehouseDetail one, String alias) { + QueryWrapper queryWrapper = new QueryWrapper() + .eq(alias + ReflectionUtil.getFieldNameToUlc(GtMaterialPointCheckIntoWarehouseDetail::getName), one.getName()) + .eq(alias + ReflectionUtil.getFieldNameToUlc(GtMaterialPointCheckIntoWarehouseDetail::getUnit), one.getUnit()) + .eq(alias + ReflectionUtil.getFieldNameToUlc(GtMaterialPointCheckIntoWarehouseDetail::getSpecification), one.getSpecification()) + .eq(alias + ReflectionUtil.getFieldNameToUlc(GtMaterialPointCheckIntoWarehouseDetail::getUnitPrice), one.getUnitPrice()) + .eq(alias + ReflectionUtil.getFieldNameToUlc(GtMaterialPointCheckIntoWarehouseDetail::getProjectSn), one.getProjectSn()); return queryWrapper; } @@ -153,6 +197,9 @@ public class GtMaterialInOutWarehouseServiceImpl extends ServiceImpl deletePointDetails) { + //10用料入库,15退库管理,20点验出库 + if (isIntoWarehouseDetail(type) && CollUtil.isNotEmpty(deletePointDetails)) { + for (GtMaterialPointCheckIntoWarehouseDetail oldPointDetail : deletePointDetails) { + QueryWrapper uniqueIntoWarehouseDetailQueryWrapper = getUniqueIntoWarehouseDetailQueryWrapper(oldPointDetail, "wd."); + List typeList = Arrays.asList(10, 15, 20); + uniqueIntoWarehouseDetailQueryWrapper.in("iow." + ReflectionUtil.getFieldNameToUlc(GtMaterialInOutWarehouse::getType), typeList); + List gtMaterialPointCheckIntoWarehouseDetails = gtMaterialPointCheckIntoWarehouseDetailMapper.getCheckIntoWarehouseDetails(typeList, uniqueIntoWarehouseDetailQueryWrapper); + if (CollUtil.isEmpty(gtMaterialPointCheckIntoWarehouseDetails)) { + gtMaterialWarehouseDetailMapper.delete(getUniqueWarehouseDetailLambdaQueryWrapper(oldPointDetail)); + } + } + } + } + @Override public Result delete(String id) { JSONObject jsonObject = JSON.parseObject(id, JSONObject.class); @@ -171,19 +238,41 @@ public class GtMaterialInOutWarehouseServiceImpl extends ServiceImpl oldPointDetails = materialPointCheckIntoWarehouseDetailService.list(getPointCheckIntoWarehouseDetailRelationLambdaQueryWrapper(gtMaterialInOutWarehouse)); - if (Objects.equals(gtMaterialInOutWarehouse.getType(), 20)) { - //出库 - oldPointDetails = getReverseGtMaterialPointCheckIntoWarehouseDetails(oldPointDetails); + Integer type = gtMaterialInOutWarehouse.getType(); + List oldPointDetails = null; + if (isIntoWarehouseDetail(type)) { + oldPointDetails = materialPointCheckIntoWarehouseDetailService.list(getPointCheckIntoWarehouseDetailRelationLambdaQueryWrapper(gtMaterialInOutWarehouse)); + if (Objects.equals(type, 20)) { + //出库 + oldPointDetails = getReverseGtMaterialPointCheckIntoWarehouseDetails(oldPointDetails); + } + useStock(oldPointDetails); } - useStock(oldPointDetails); LambdaQueryWrapper queryWrapper = getPointCheckIntoWarehouseDetailRelationLambdaQueryWrapper(gtMaterialInOutWarehouse); materialPointCheckIntoWarehouseDetailService.remove(queryWrapper); + + deleteNotIntoMaterialDetailFromWarehouseDetail(type, oldPointDetails); } return result; } + /** + * 是否进入库存管理表 + * + * @return + */ + private boolean isIntoWarehouseDetail(Integer type) { + List typeList = Arrays.asList(10, 15, 20); + return type != null && typeList.contains(type); + } + + /** + * 获取出入库单号对应的物料详情 + * + * @param gtMaterialInOutWarehouse + * @return + */ private LambdaQueryWrapper getPointCheckIntoWarehouseDetailRelationLambdaQueryWrapper(GtMaterialInOutWarehouse gtMaterialInOutWarehouse) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() .eq(GtMaterialPointCheckIntoWarehouseDetail::getGtMaterialInOutWarehouseId, gtMaterialInOutWarehouse.getId()); @@ -197,7 +286,8 @@ public class GtMaterialInOutWarehouseServiceImpl extends ServiceImpl oldPointDetails, GtMaterialInOutWarehouse gtMaterialInOutWarehouseEntity) { - if (Objects.equals(gtMaterialInOutWarehouseEntity.getType(), 10)) { + if (Objects.equals(gtMaterialInOutWarehouseEntity.getType(), 10) || + Objects.equals(gtMaterialInOutWarehouseEntity.getType(), 15)) { //入库 useStock(oldPointDetails); saveGtMaterialWarehouseDetail(gtMaterialInOutWarehouseEntity);