立档单位-库房-档案柜默认值

new
JiilingLee 1 year ago
parent 21e3f430db
commit 8ec8a1ef6b

@ -1,5 +1,11 @@
package cn.iocoder.yudao.module.accounting.service.voucher; 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 org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -26,11 +32,38 @@ public class VoucherServiceImpl implements VoucherService {
@Resource @Resource
private VoucherMapper voucherMapper; private VoucherMapper voucherMapper;
@Resource
private OrganizationMapper organizationMapper;
@Resource
private DepotMapper depotMapper;
@Resource
private DepotCabinetMapper depotCabinetMapper;
@Override @Override
public Long createVoucher(VoucherCreateReqVO createReqVO) { public Long createVoucher(VoucherCreateReqVO createReqVO) {
// 插入 // 插入
VoucherDO voucher = VoucherConvert.INSTANCE.convert(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); voucherMapper.insert(voucher);
// 返回 // 返回
return voucher.getId(); return voucher.getId();
@ -42,6 +75,27 @@ public class VoucherServiceImpl implements VoucherService {
validateVoucherExists(updateReqVO.getId()); validateVoucherExists(updateReqVO.getId());
// 更新 // 更新
VoucherDO updateObj = VoucherConvert.INSTANCE.convert(updateReqVO); 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); voucherMapper.updateById(updateObj);
} }

@ -99,6 +99,39 @@ public class OrganizationServiceImpl implements OrganizationService {
public List<OrganizationDepotVO> getOrganizationTree() { public List<OrganizationDepotVO> getOrganizationTree() {
List<OrganizationDepotVO> organizationDepotCabinets = organizationMapper.getOrganizationDepotCabinets(); List<OrganizationDepotVO> organizationDepotCabinets = organizationMapper.getOrganizationDepotCabinets();
List<OrganizationDepotVO> merge = this.merge(organizationDepotCabinets); List<OrganizationDepotVO> merge = this.merge(organizationDepotCabinets);
for (OrganizationDepotVO or:merge
) {
if (or.getChildren().size()<1){
List<DepotVo> depotVoList = new ArrayList<>();
DepotVo depotVo = new DepotVo();
depotVo.setDepotId(0L);
depotVo.setDepotCode("0");
depotVo.setDepotName("默认库房");
List<DepotCabinetVo> 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<DepotVo> 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<DepotCabinetVo> depotCabinetVoList = new ArrayList<>();
depotCabinetVoList.add(depotCabinetVo);
depotVo.setChildren(depotCabinetVoList);
}
}
}
}
return merge; return merge;
} }

Loading…
Cancel
Save