@ -1,6 +1,8 @@
package com.glxp.api.controller.basic ;
import cn.hutool.core.collection.CollUtil ;
import cn.hutool.core.util.IdUtil ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.github.pagehelper.PageInfo ;
import com.glxp.api.annotation.AuthRuleAnnotation ;
import com.glxp.api.common.enums.ResultEnum ;
@ -9,6 +11,7 @@ import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.ConstantStatus ;
import com.glxp.api.entity.auth.AuthAdmin ;
import com.glxp.api.entity.basic.BasicCorpEntity ;
import com.glxp.api.entity.sup.UserCompanyEntity ;
import com.glxp.api.exception.JsonException ;
import com.glxp.api.req.basic.BasicUnitMaintainFilterRequest ;
import com.glxp.api.req.system.DeleteRequest ;
@ -16,6 +19,7 @@ import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.basic.BasicCorpResponse ;
import com.glxp.api.service.auth.AuthAdminService ;
import com.glxp.api.service.basic.BasicCorpService ;
import com.glxp.api.service.sup.UserCompanyService ;
import com.glxp.api.util.CustomUtil ;
import org.springframework.beans.BeanUtils ;
import org.springframework.validation.BindingResult ;
@ -52,6 +56,8 @@ public class BasicCorpController {
}
List < BasicCorpResponse > basicUnitMaintainEntities ;
basicUnitMaintainEntities = basicUnitMaintainService . filterList ( basicUnitMaintainFilterRequest ) ;
PageInfo < BasicCorpResponse > pageInfo = new PageInfo < > ( basicUnitMaintainEntities ) ;
PageSimpleResponse < BasicCorpResponse > pageSimpleResponse = new PageSimpleResponse < > ( ) ;
pageSimpleResponse . setTotal ( pageInfo . getTotal ( ) ) ;
@ -60,6 +66,9 @@ public class BasicCorpController {
return ResultVOUtils . success ( pageSimpleResponse ) ;
}
@Resource
UserCompanyService userCompanyService ;
@GetMapping ( "/udiwms/basic/unit/app/filter" )
public BaseResponse filterAppBasicUnit ( BasicUnitMaintainFilterRequest basicUnitMaintainFilterRequest ,
BindingResult bindingResult ) {
@ -67,14 +76,25 @@ public class BasicCorpController {
if ( bindingResult . hasErrors ( ) ) {
return ResultVOUtils . error ( ResultEnum . PARAM_VERIFY_FALL , bindingResult . getFieldError ( ) . getDefaultMessage ( ) ) ;
}
if ( basicUnitMaintainFilterRequest . getCompanyIdFk ( ) = = null )
return ResultVOUtils . error ( 500 , "企业ID不能为空! " ) ;
List < BasicCorpResponse > basicUnitMaintainEntities ;
long customerCount = basicUnitMaintainService . count ( new QueryWrapper < BasicCorpEntity > ( ) . eq ( "companyIdFk" , basicUnitMaintainFilterRequest . getCompanyIdFk ( ) ) . eq ( "corpType" , 1 ) ) ;
long supplierCount = basicUnitMaintainService . count ( new QueryWrapper < BasicCorpEntity > ( ) . eq ( "companyIdFk" , basicUnitMaintainFilterRequest . getCompanyIdFk ( ) ) . eq ( "corpType" , 2 ) ) ;
basicUnitMaintainEntities = basicUnitMaintainService . filterList ( basicUnitMaintainFilterRequest ) ;
if ( CollUtil . isNotEmpty ( basicUnitMaintainEntities ) ) {
for ( BasicCorpResponse basicCorpResponse : basicUnitMaintainEntities ) {
long i = userCompanyService . count ( new QueryWrapper < UserCompanyEntity > ( ) . eq ( "creditNum" , basicCorpResponse . getCreditNo ( ) ) ) ;
if ( i > 0 ) {
basicCorpResponse . setRegStatus ( 1 ) ;
} else
basicCorpResponse . setRegStatus ( 3 ) ;
}
}
PageInfo < BasicCorpResponse > pageInfo = new PageInfo < > ( basicUnitMaintainEntities ) ;
PageSimpleResponse < BasicCorpResponse > pageSimpleResponse = new PageSimpleResponse < > ( ) ;
pageSimpleResponse . setSupplierCount ( customerCount ) ;
pageSimpleResponse . setCustomerCount ( supplierCount ) ;
pageSimpleResponse . setTotal ( pageInfo . getTotal ( ) ) ;
pageSimpleResponse . setList ( basicUnitMaintainEntities ) ;
@ -166,6 +186,7 @@ public class BasicCorpController {
String companyId = request . getHeader ( "companyId" ) ;
return companyId ;
}
public String getCustomerId ( ) {
ServletRequestAttributes attributes = ( ServletRequestAttributes ) RequestContextHolder . getRequestAttributes ( ) ;
if ( attributes = = null ) {