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; }