@ -28,14 +28,21 @@ package com.yxt.base.biz.base.basesuppliertype;
import cn.hutool.core.bean.BeanUtil ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.baomidou.mybatisplus.core.metadata.IPage ;
import com.yxt.base.feign.portal.sysorganization.SysOrganizationFeign ;
import com.yxt.base.feign.portal.sysorganization.SysOrganizationVo ;
import com.yxt.base.feign.portal.sysstafforg.SysStaffOrgFeign ;
import com.yxt.common.base.service.MybatisBaseService ;
import com.yxt.common.base.utils.PagerUtil ;
import com.yxt.common.core.query.PagerQuery ;
import com.yxt.common.core.result.ResultBean ;
import com.yxt.common.core.vo.PagerVo ;
import org.apache.commons.lang3.StringUtils ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.stereotype.Service ;
import java.util.Arrays ;
import java.util.List ;
/ * *
* Project : yxt - base ( 仓储基础信息供应商 ) < br / >
* File : BaseSupplierTypeService . java < br / >
@ -51,7 +58,12 @@ import org.springframework.stereotype.Service;
* /
@Service
public class BaseSupplierTypeService extends MybatisBaseService < BaseSupplierTypeMapper , BaseSupplierType > {
@Autowired
private SysOrganizationFeign sysOrganizationFeign ;
@Autowired
private SysStaffOrgFeign sysStaffOrgFeign ;
public PagerVo < BaseSupplierTypeVo > listPageVo ( PagerQuery < BaseSupplierTypeQuery > pq ) {
BaseSupplierTypeQuery query = pq . getParams ( ) ;
QueryWrapper < BaseSupplierType > qw = new QueryWrapper < > ( ) ;
@ -64,17 +76,43 @@ public class BaseSupplierTypeService extends MybatisBaseService<BaseSupplierType
public ResultBean saveOrUpdateDto ( BaseSupplierTypeDto dto ) {
ResultBean rb = ResultBean . fireFail ( ) ;
String dtoSid = dto . getSid ( ) ;
String supplierTypeCode = dto . getSupplierTypeCode ( ) ;
String createOrgSid = dto . getCreateOrgSid ( ) ;
if ( StringUtils . isBlank ( dtoSid ) ) {
int i = baseMapper . checkSaveCode ( supplierTypeCode , createOrgSid ) ;
String deptName = "" ;
String deptSid = "" ;
String createOrgSid = "" ;
String orgPath = dto . getOrgPath ( ) ;
if ( StringUtils . isNotBlank ( orgPath ) ) {
List < String > split = Arrays . asList ( orgPath . split ( "/" ) ) ;
if ( split . size ( ) > 1 ) {
//获取本级sid获取本级部门信息
SysOrganizationVo sysOrganization = sysOrganizationFeign . fetchBySid ( split . get ( split . size ( ) - 2 ) ) . getData ( ) ;
SysOrganizationVo sysOrganization1 = sysOrganizationFeign . fetchBySid ( split . get ( split . size ( ) - 1 ) ) . getData ( ) ;
deptName = sysOrganization . getName ( ) + "/" + sysOrganization1 . getName ( ) ;
deptName = sysOrganization1 . getName ( ) ;
deptSid = sysOrganization1 . getSid ( ) ;
} else {
SysOrganizationVo sysOrganization = sysOrganizationFeign . fetchBySid ( split . get ( 0 ) ) . getData ( ) ;
deptName = sysOrganization . getName ( ) ;
deptName = sysOrganization . getName ( ) ;
deptSid = sysOrganization . getSid ( ) ;
}
dto . setUseOrgSid ( deptSid ) ;
createOrgSid = sysStaffOrgFeign . getOrgSidByPath ( orgPath ) . getData ( ) ;
//创建组织使用组织
ResultBean < SysOrganizationVo > organizationResultBean = sysOrganizationFeign . fetchBySid ( createOrgSid ) ;
if ( organizationResultBean . getData ( ) ! = null ) {
dto . setCreateOrgSid ( createOrgSid ) ;
dto . setCreateOrgName ( organizationResultBean . getData ( ) . getName ( ) ) ;
}
}
int i = baseMapper . checkSaveCode ( dto . getSupplierTypeCode ( ) , dto . getUseOrgSid ( ) ) ;
if ( i > 0 ) {
return rb . setMsg ( "新增编码已存在,请重新输入" ) ;
}
this . insertByDto ( dto ) ;
return rb . success ( ) ;
}
int i = baseMapper . checkUpdateCode ( supplierTypeCode , createOrgSid , dtoSid ) ;
int i = baseMapper . checkUpdateCode ( dto . getSupplierTypeCode ( ) , dto . getUseOrgSid ( ) , dtoSid ) ;
if ( i > 0 ) {
return rb . setMsg ( "修改编码已存在,请重新输入" ) ;
}