From 8ec8a1ef6b850a3d0183337f830ff566ed1c8050 Mon Sep 17 00:00:00 2001 From: JiilingLee <462362@qq.com> Date: Mon, 9 Oct 2023 13:57:35 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=8B=E6=A1=A3=E5=8D=95=E4=BD=8D-=E5=BA=93?= =?UTF-8?q?=E6=88=BF-=E6=A1=A3=E6=A1=88=E6=9F=9C=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/voucher/VoucherServiceImpl.java | 54 +++++++++++++++++++ .../organization/OrganizationServiceImpl.java | 33 ++++++++++++ 2 files changed, 87 insertions(+) diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/voucher/VoucherServiceImpl.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/voucher/VoucherServiceImpl.java index 62c09991..59114180 100644 --- a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/voucher/VoucherServiceImpl.java +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/voucher/VoucherServiceImpl.java @@ -1,5 +1,11 @@ package cn.iocoder.yudao.module.accounting.service.voucher; +import cn.iocoder.yudao.module.setting.dal.dataobject.depot.DepotDO; +import cn.iocoder.yudao.module.setting.dal.dataobject.depotcabinet.DepotCabinetDO; +import cn.iocoder.yudao.module.setting.dal.dataobject.organization.OrganizationDO; +import cn.iocoder.yudao.module.setting.dal.mysql.depot.DepotMapper; +import cn.iocoder.yudao.module.setting.dal.mysql.depotcabinet.DepotCabinetMapper; +import cn.iocoder.yudao.module.setting.dal.mysql.organization.OrganizationMapper; import org.springframework.stereotype.Service; import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; @@ -26,11 +32,38 @@ public class VoucherServiceImpl implements VoucherService { @Resource private VoucherMapper voucherMapper; + @Resource + private OrganizationMapper organizationMapper; + @Resource + private DepotMapper depotMapper; + @Resource + private DepotCabinetMapper depotCabinetMapper; @Override public Long createVoucher(VoucherCreateReqVO createReqVO) { // 插入 VoucherDO voucher = VoucherConvert.INSTANCE.convert(createReqVO); + Long organizationId = createReqVO.getOrganizationId(); + Long depotId = createReqVO.getDepotId(); + Long cabinetId = createReqVO.getCabinetId(); + OrganizationDO organizationDO = organizationMapper.selectById(organizationId); + DepotDO depotDO = depotMapper.selectById(depotId); + DepotCabinetDO depotCabinetDO = depotCabinetMapper.selectById(cabinetId); + String position=""; + if (organizationDO != null){ + position=position+"/"+organizationDO.getOrganizationName(); + if (depotDO != null){ + position=position+"/"+depotDO.getName(); + if (depotCabinetDO != null){ + position= position+"/"+depotCabinetDO.getName(); + }else { + position= position+"/默认档案柜"; + } + }else { + position=position+"/默认库房/默认档案柜"; + } + } + voucher.setPosition(position); voucherMapper.insert(voucher); // 返回 return voucher.getId(); @@ -42,6 +75,27 @@ public class VoucherServiceImpl implements VoucherService { validateVoucherExists(updateReqVO.getId()); // 更新 VoucherDO updateObj = VoucherConvert.INSTANCE.convert(updateReqVO); + Long organizationId = updateObj.getOrganizationId(); + Long depotId = updateObj.getDepotId(); + Long cabinetId = updateObj.getCabinetId(); + OrganizationDO organizationDO = organizationMapper.selectById(organizationId); + DepotDO depotDO = depotMapper.selectById(depotId); + DepotCabinetDO depotCabinetDO = depotCabinetMapper.selectById(cabinetId); + String position=""; + if (organizationDO != null){ + position=position+organizationDO.getOrganizationName(); + if (depotDO != null){ + position=position+"/"+depotDO.getName(); + if (depotCabinetDO != null){ + position= position+"/"+depotCabinetDO.getName(); + }else { + position= position+"/默认档案柜"; + } + }else { + position=position+"/默认库房/默认档案柜"; + } + } + updateObj.setPosition(position); voucherMapper.updateById(updateObj); } diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/organization/OrganizationServiceImpl.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/organization/OrganizationServiceImpl.java index 7ca7ffa2..c1dc2e09 100644 --- a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/organization/OrganizationServiceImpl.java +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/organization/OrganizationServiceImpl.java @@ -99,6 +99,39 @@ public class OrganizationServiceImpl implements OrganizationService { public List getOrganizationTree() { List organizationDepotCabinets = organizationMapper.getOrganizationDepotCabinets(); List merge = this.merge(organizationDepotCabinets); + for (OrganizationDepotVO or:merge + ) { + if (or.getChildren().size()<1){ + List depotVoList = new ArrayList<>(); + DepotVo depotVo = new DepotVo(); + depotVo.setDepotId(0L); + depotVo.setDepotCode("0"); + depotVo.setDepotName("默认库房"); + List depotCabinetVoList = new ArrayList<>(); + DepotCabinetVo depotCabinetVo = new DepotCabinetVo(); + depotCabinetVo.setCabinetId(0L); + depotCabinetVo.setCabinetCode("0"); + depotCabinetVo.setCabinetName("默认档案柜"); + depotCabinetVoList.add(depotCabinetVo); + depotVo.setChildren(depotCabinetVoList); + depotVoList.add(depotVo); + or.setChildren(depotVoList); + }else { + List children = or.getChildren(); + for (DepotVo depotVo:children + ) { + if (depotVo.getChildren().size()<1){ + DepotCabinetVo depotCabinetVo = new DepotCabinetVo(); + depotCabinetVo.setCabinetId(0L); + depotCabinetVo.setCabinetCode("0"); + depotCabinetVo.setCabinetName("默认档案柜"); + List depotCabinetVoList = new ArrayList<>(); + depotCabinetVoList.add(depotCabinetVo); + depotVo.setChildren(depotCabinetVoList); + } + } + } + } return merge; }