From fa45344904672bf20bee5b57f8fa7418a742407d Mon Sep 17 00:00:00 2001 From: PQZ Date: Thu, 24 Oct 2024 16:31:10 +0800 Subject: [PATCH] 1 --- .../project/service/RepairWaresService.java | 9 ++ .../service/impl/RepairWaresServiceImpl.java | 13 +++ .../stockOperate/entity/DlRepairSo.java | 7 ++ .../stockOperate/entity/DlRepairSoi.java | 10 +- .../service/DlRepairSoService.java | 24 ++-- .../service/DlRepairSoiService.java | 19 +++- .../service/impl/DlRepairSoServiceImpl.java | 104 +++++++++++++++--- .../service/impl/DlRepairSoiServiceImpl.java | 13 +++ .../stockOperate/vo/DlRepairSoReqVO.java | 5 + 9 files changed, 179 insertions(+), 25 deletions(-) diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/RepairWaresService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/RepairWaresService.java index aae23399..cc123d5c 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/RepairWaresService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/RepairWaresService.java @@ -71,4 +71,13 @@ public interface RepairWaresService extends IService { * @return java.util.List> **/ List> getAllTypeList(); + + /** + * 通过id查询集合 + * @author PQZ + * @date 14:56 2024/10/24 + * @param idList waresId集合 + * @return java.util.List + **/ + List listByIds(List idList); } \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/impl/RepairWaresServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/impl/RepairWaresServiceImpl.java index 2f92619c..62aa262a 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/impl/RepairWaresServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/impl/RepairWaresServiceImpl.java @@ -114,4 +114,17 @@ public class RepairWaresServiceImpl extends ServiceImpl + * @author PQZ + * @date 14:56 2024/10/24 + **/ + @Override + public List listByIds(List idList) { + return baseMapper.selectBatchIds(idList); + } + } \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/entity/DlRepairSo.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/entity/DlRepairSo.java index 9e185191..7293b598 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/entity/DlRepairSo.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/entity/DlRepairSo.java @@ -112,6 +112,13 @@ public class DlRepairSo extends TenantBaseDO { /** 关联的配件申请单的id(dl_ticket_wares表的ID) */ private String twId; + /** 关联主表id */ + private String mainId; + + /** 关联主表名称 */ + private String mainTable; + + /** * 车牌号 */ diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/entity/DlRepairSoi.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/entity/DlRepairSoi.java index dc8eebdc..f4978b01 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/entity/DlRepairSoi.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/entity/DlRepairSoi.java @@ -31,7 +31,7 @@ public class DlRepairSoi extends TenantBaseDO { private String id; /** - * 采购单/领料单ID(dl_repair_so表的ID) + * 采购单/领料单ID/入库单(dl_repair_so表的ID) */ private String soId; @@ -69,6 +69,14 @@ public class DlRepairSoi extends TenantBaseDO { * 备注 */ private String remark; + /** + * 入库数量 + */ + private Integer inCount; + /** + * 原始id + */ + private String rawId; /** * 配件信息 diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/DlRepairSoService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/DlRepairSoService.java index 47101b45..8893fd34 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/DlRepairSoService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/DlRepairSoService.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.module.stockOperate.service; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSo; import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoReqVO; import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoRespVO; @@ -10,16 +9,18 @@ import com.baomidou.mybatisplus.extension.service.IService; /** * 针对表【dl_repair_so(采购单领料单)】的数据库操作Service + * * @author 小李 * @date 9:09 2024/9/13 -**/ + **/ public interface DlRepairSoService extends IService { /** * 采购单/领料单 新增 + * + * @param repairSoRespVO 采购单对象 * @author 小李 * @date 10:49 2024/9/14 - * @param repairSoRespVO 采购单对象 **/ void createRepairSo(DlRepairSoRespVO repairSoRespVO); @@ -35,36 +36,45 @@ public interface DlRepairSoService extends IService { /** * 采购单/领料单 作废 * + * @param repairSoReqVO 作废对象 * @author 小李 * @date 11:12 2024/9/18 - * @param repairSoReqVO 作废对象 **/ void voidRepairSo(DlRepairSoReqVO repairSoReqVO); /** * 采购单/领料单 查看 * + * @param id 主键 * @author 小李 * @date 9:34 2024/9/22 - * @param id 主键 **/ DlRepairSoRespVO getRepairSoById(String id); /** * 员工确认领料 * + * @param id 单据ID 领料单主表 * @author 小李 * @date 11:58 2024/10/21 - * @param id 单据ID 领料单主表 **/ void confirmGet(String id); /** * 员工确认退料 * + * @param id 退料单主表ID * @author 小李 * @date 19:41 2024/10/21 - * @param id 退料单主表ID **/ void confirmBack(String id); + + /** + * 采购入库 + * + * @param reqVO (接参实体中需传入:采购单id,子表中商品id,子表中入库数量inCount) + * @author PQZ + * @date 14:32 2024/10/24 + **/ + void inWare(DlRepairSoReqVO reqVO); } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/DlRepairSoiService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/DlRepairSoiService.java index 989e685a..2169096a 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/DlRepairSoiService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/DlRepairSoiService.java @@ -11,35 +11,46 @@ import java.util.List; /** * 针对表【dl_repair_soi(采购单领料单子表)】的数据库操作Service + * * @author 小李 * @date 9:09 2024/9/13 -**/ + **/ public interface DlRepairSoiService extends IService { /** * 采购单领料单子表 分页 * + * @param repairSoiReqVO 查询对象 * @author 小李 * @date 10:44 2024/9/18 - * @param repairSoiReqVO 查询对象 **/ IPage getRepairSoiPage(DlRepairSoiReqVO repairSoiReqVO, Page page); /** * 采购单领料单子表详细 按ID查 * + * @param ids ids * @author 小李 * @date 11:24 2024/9/22 - * @param ids ids **/ List getRepairSoiByIds(List ids); /** * 按主表ID查 * + * @param soId 主表ID * @author 小李 * @date 11:22 2024/10/21 - * @param soId 主表ID **/ List getRepairSoiBySoId(String soId); + + /** + * 根据关联配件id查询关联配件 + * + * @param ids 配件id集合 + * @return java.util.List + * @author PQZ + * @date 14:39 2024/10/24 + **/ + List listByIds(List ids); } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java index cde8ddb9..44536258 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java @@ -20,6 +20,8 @@ import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoReqVO; import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoRespVO; import cn.iocoder.yudao.module.system.api.dept.DeptApi; import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import cn.iocoder.yudao.module.tickets.entity.DlRepairTickets; import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem; import cn.iocoder.yudao.module.tickets.entity.DlTicketWares; @@ -39,10 +41,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -90,6 +89,8 @@ public class DlRepairSoServiceImpl extends ServiceImpl list = repairSoiService.list(new LambdaQueryWrapper().eq(DlRepairSoi::getSoId, result.getId())); - if(!list.isEmpty()){ + if (!list.isEmpty()) { //所有有配件的分类 - List> typeMapList = waresService.getAllTypeList(); - Map typeMap = new HashMap<>(); - for(Map map:typeMapList){ - typeMap.put(map.get("id"),map.get("name")); + List> typeMapList = waresService.getAllTypeList(); + Map typeMap = new HashMap<>(); + for (Map map : typeMapList) { + typeMap.put(map.get("id"), map.get("name")); } //关联查配件信息 List repairWaresList = waresService.listByIds(list.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList())); - Map waresMap = repairWaresList.stream().collect(Collectors.toMap(RepairWares::getId, Function.identity())); - list.forEach(item->{ + Map waresMap = repairWaresList.stream().collect(Collectors.toMap(RepairWares::getId, Function.identity())); + list.forEach(item -> { item.setWares(waresMap.get(item.getGoodsId())); item.setTypeName(typeMap.get(item.getWares().getType())); }); @@ -371,7 +372,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl().eq(DlRepairTickets::getId, ticketWares.getTicketId())); @@ -396,6 +397,83 @@ public class DlRepairSoServiceImpl extends ServiceImpl filterWare = reqVO.getSoiList().stream().filter(item -> item.getInCount() != null && item.getInCount() > 0).collect(Collectors.toList()); + //即将入库采购品 + List pmsWaresList = repairSoiService.listByIds(filterWare.stream().map(DlRepairSoi::getId).collect(Collectors.toList())); + //初始化本次入库采购品 + List inWaresList = new ArrayList<>(); + //原始配件库相关配件 + List waresList = waresService.listByIds(pmsWaresList.stream().map(DlRepairSoi::getWareId).collect(Collectors.toList())); + + /*2、采购单转入库单*/ + //入库单关联采购单 + inSo.setMainId(dlRepairSo.getId()); + inSo.setMainTable("dl_repair_so"); + //05表示入库单 + inSo.setSoType("05"); + //入库单号 + inSo.setSoNo(reqVO.getSoNo()); + //入库人 + inSo.setUserId(userId); + inSo.setUserName(user.getNickname()); + //入库时间 + inSo.setSoTime(new Date()); + //入库商品总价 + inSo.setTotalPrice(reqVO.getTotalPrice()); + save(inSo); + + /*3、入库配件处理*/ + Map filterWareMap = filterWare.stream().collect(Collectors.toMap(DlRepairSoi::getId, soi -> soi)); + pmsWaresList.forEach(item -> { + DlRepairSoi filterSoi = filterWareMap.get(item.getId()); + DlRepairSoi inWares = item; + //采购单id + inWares.setSoId(inSo.getId()); + //采购品原始id + inWares.setRawId(item.getId()); + //入库数量 + inWares.setInCount(filterSoi.getInCount()); + inWares.setId(null); + //采购品中入库数量字段累加 + item.setInCount(item.getInCount() == null?0:item.getInCount()+filterSoi.getInCount()); + inWaresList.add(inWares); + }); + //更新采购品 + repairSoiService.updateBatchById(pmsWaresList); + //新增入库采购品 + repairSoiService.saveBatch(inWaresList); + + /*4、原始配件库处理*/ + Map wareMap = filterWare.stream().collect(Collectors.toMap(DlRepairSoi::getWareId, soi -> soi)); + waresList.forEach(item -> { + DlRepairSoi filterSoi = wareMap.get(item.getId()); + item.setStock((item.getStock()==null?new BigDecimal(0):item.getStock()).add(new BigDecimal(filterSoi.getInCount()))); + }); + waresService.updateBatchById(waresList); + + + + } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoiServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoiServiceImpl.java index 4c6a2cd0..c6ee1e14 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoiServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoiServiceImpl.java @@ -107,6 +107,19 @@ public class DlRepairSoiServiceImpl extends ServiceImpl + * @author PQZ + * @date 14:39 2024/10/24 + **/ + @Override + public List listByIds(List ids) { + return baseMapper.selectBatchIds(ids); + } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/vo/DlRepairSoReqVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/vo/DlRepairSoReqVO.java index d9c4b607..d0a27f01 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/vo/DlRepairSoReqVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/vo/DlRepairSoReqVO.java @@ -1,11 +1,13 @@ package cn.iocoder.yudao.module.stockOperate.vo; import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSo; +import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSoi; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; import java.util.Date; +import java.util.List; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @@ -20,4 +22,7 @@ public class DlRepairSoReqVO extends DlRepairSo { @Schema(description = "时间区间") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private Date[] searchTimeArray; + + /**关联商品*/ + List soiList; }