@ -10,9 +10,11 @@ import java.time.Instant;
import java.time.LocalDateTime ;
import java.time.ZoneId ;
import java.time.temporal.ChronoUnit ;
import java.util.ArrayList ;
import java.util.HashMap ;
import java.util.List ;
import java.util.Map ;
import java.util.stream.Collectors ;
import cn.hutool.core.convert.Convert ;
import cn.hutool.core.util.IdUtil ;
@ -20,25 +22,23 @@ import com.alibaba.fastjson.JSON;
import com.zdxt.auth.dto.UserBean ;
import com.zdxt.auth.feign.FileUploadApi ;
import com.zdxt.auth.feign.UserApi ;
import com.zdxt.code.domain.EnterpriseMerchantAuthorization ;
import com.zdxt.code.domain.QrCodeGenerateHistory ;
import com.zdxt.auth.project.system.dict.mapper.DictDataMapper ;
import com.zdxt.code.domain.* ;
import com.zdxt.code.service.IEnterpriseMerchantAuthorizationService ;
import com.zdxt.code.service.IQrCodeGenerateHistoryService ;
import com.zdxt.code.service.ISsztJbxx110497Service ;
import com.zdxt.code.utils.CrawlerUtil ;
import com.zdxt.code.utils.HttpUtil ;
import com.zdxt.code.utils.PasswordTools ;
import com.zdxt.code.utils.QRCodeUtil ;
import com.zdxt.common.util.DateUtils ;
import com.zdxt.common.util.StringUtils ;
import lombok.extern.slf4j.Slf4j ;
import com.zdxt.domain.auth.DictData ;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Value ;
import org.springframework.stereotype.Service ;
import com.zdxt.code.mapper.EnterpriseInformationMapper ;
import com.zdxt.code.domain.EnterpriseInformation ;
import com.zdxt.code.service.IEnterpriseInformationService ;
import org.springframework.web.multipart.MultipartFile ;
@ -78,6 +78,9 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS
@Autowired
private ISsztJbxx110497Service ssztJbxx110497Service ;
@Autowired
private DictDataMapper dictDataMapper ;
/ * *
* 查询企业信息登记
*
@ -85,17 +88,16 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS
* @return 企业信息登记
* /
@Override
public EnterpriseInformation selectEnterpriseInformationById ( String id )
{
public EnterpriseInformation selectEnterpriseInformationById ( String id ) {
EnterpriseInformation enterpriseInformation = enterpriseInformationMapper . selectEnterpriseInformationById ( id ) ;
QrCodeGenerateHistory qrCodeGenerateHistory =
iQrCodeGenerateHistoryService . selectQrCodeGenerateHistoryByNewest ( enterpriseInformation . getEnterpriseNumber ( ) ) ;
enterpriseInformation . setQrCodeGenerateHistory ( qrCodeGenerateHistory ) ;
return enterpriseInformation ;
}
@Override
public EnterpriseInformation selectEnterpriseInformationByNum ( String num )
{
public EnterpriseInformation selectEnterpriseInformationByNum ( String num ) {
EnterpriseInformation enterpriseInformation = enterpriseInformationMapper . selectEnterpriseInformationByNum ( num ) ;
QrCodeGenerateHistory qrCodeGenerateHistory =
iQrCodeGenerateHistoryService . selectQrCodeGenerateHistoryByNewest ( enterpriseInformation . getEnterpriseNumber ( ) ) ;
@ -115,8 +117,7 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS
* @return 企业信息登记
* /
@Override
public List < EnterpriseInformation > selectEnterpriseInformationList ( EnterpriseInformation enterpriseInformation )
{
public List < EnterpriseInformation > selectEnterpriseInformationList ( EnterpriseInformation enterpriseInformation ) {
// if ("3".equals(enterpriseInformation.getReason())) {
// Map<String, Object> tmp = new HashMap<>();
// tmp.put("reason", 3);
@ -124,9 +125,9 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS
// }
return enterpriseInformationMapper . selectEnterpriseInformationList ( enterpriseInformation ) ;
}
@Override
public List < EnterpriseInformation > selectEnterpriseInformationList1 ( EnterpriseInformation enterpriseInformation )
{
public List < EnterpriseInformation > selectEnterpriseInformationList1 ( EnterpriseInformation enterpriseInformation ) {
// if ("3".equals(enterpriseInformation.getReason())) {
// Map<String, Object> tmp = new HashMap<>();
// tmp.put("reason", 3);
@ -134,6 +135,7 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS
// }
return enterpriseInformationMapper . selectEnterpriseInformationList1 ( enterpriseInformation ) ;
}
@Override
public List < EnterpriseInformation > selectEnterpriseInformationAndQrInfo ( EnterpriseInformation enterpriseInformation ) {
return enterpriseInformationMapper . selectEnterpriseInformationAndQrInfo ( enterpriseInformation ) ;
@ -146,8 +148,7 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS
* @return 结果
* /
@Override
public int insertEnterpriseInformation ( EnterpriseInformation enterpriseInformation )
{
public int insertEnterpriseInformation ( EnterpriseInformation enterpriseInformation ) {
enterpriseInformation . setCreateTime ( DateUtils . getNowDate ( ) ) ;
enterpriseInformation . setId ( IdUtil . simpleUUID ( ) ) ;
// UserBean user = userApi.getCurrentUser();
@ -164,13 +165,13 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS
enterpriseInformation1 . setEnterpriseNumber ( enterpriseInformation . getEnterpriseNumber ( ) ) ;
List < EnterpriseInformation > enterpriseInformations = enterpriseInformationMapper . selectEnterpriseInformationList ( enterpriseInformation1 ) ;
int i = 0 ;
if ( enterpriseInformations . size ( ) = = 0 ) {
int i = 0 ;
if ( enterpriseInformations . size ( ) = = 0 ) {
i = enterpriseInformationMapper . insertEnterpriseInformation ( enterpriseInformation ) ;
} else {
i = enterpriseInformationMapper . updateEnterpriseInformationByEnterpriseNumber ( enterpriseInformation ) ;
}
if ( i > 0 ) {
if ( i > 0 ) {
// String text = salt;
String uuid = IdUtil . simpleUUID ( ) ;
Map < String , String > jsonMap = new HashMap < > ( ) ;
@ -197,7 +198,7 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS
//变更原因
qrCodeGenerateHistory . setReasonsChange ( "登记" ) ;
iQrCodeGenerateHistoryService . insertQrCodeGenerateHistory ( qrCodeGenerateHistory ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
e . printStackTrace ( ) ;
}
@ -223,11 +224,10 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS
* @return 结果
* /
@Override
public int updateEnterpriseInformation ( EnterpriseInformation enterpriseInformation )
{
public int updateEnterpriseInformation ( EnterpriseInformation enterpriseInformation ) {
enterpriseInformation . setUpdateTime ( DateUtils . getNowDate ( ) ) ;
int i = enterpriseInformationMapper . updateEnterpriseInformation ( enterpriseInformation ) ;
if ( i > 0 ) {
if ( i > 0 ) {
// 修改二维码信息, 改为已失效
EnterpriseInformation tmp = this . selectEnterpriseInformationById ( enterpriseInformation . getId ( ) ) ;
QrCodeGenerateHistory qrc = new QrCodeGenerateHistory ( ) ;
@ -252,8 +252,7 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS
* @return 结果
* /
@Override
public int deleteEnterpriseInformationByIds ( String ids )
{
public int deleteEnterpriseInformationByIds ( String ids ) {
return enterpriseInformationMapper . deleteEnterpriseInformationByIds ( Convert . toStrArray ( ids ) ) ;
}
@ -262,7 +261,7 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS
EnterpriseInformation enterpriseInformation = new EnterpriseInformation ( ) ;
enterpriseInformation . setEnterpriseNumber ( enterpriseNumber ) ;
List < EnterpriseInformation > enterpriseInformations = enterpriseInformationMapper . selectEnterpriseInformationList ( enterpriseInformation ) ;
if ( enterpriseInformations . size ( ) = = 0 ) {
if ( enterpriseInformations . size ( ) = = 0 ) {
return 0 ;
}
//查询最新的二维码数据
@ -277,7 +276,7 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS
LocalDateTime date2 = LocalDateTime . now ( ) ;
//判断相差多少个小时
long hoursDiff = ChronoUnit . HOURS . between ( date1 , date2 ) ;
if ( hoursDiff < 24 ) {
if ( hoursDiff < 24 ) {
log . error ( "二维码生成时间不足24小时" ) ;
return 0 ;
}
@ -290,7 +289,7 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS
File encode = QRCodeUtil . encodeFile ( text , logoPath , filePath , true ) ;
MultipartFile multipartFile = QRCodeUtil . getMultipartFile ( encode ) ;
upload = fileUploadApi . upload ( multipartFile ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
e . printStackTrace ( ) ;
}
//作废之前的二维码数据
@ -321,8 +320,7 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS
* @return 结果
* /
@Override
public int deleteEnterpriseInformationById ( String id )
{
public int deleteEnterpriseInformationById ( String id ) {
return enterpriseInformationMapper . deleteEnterpriseInformationById ( id ) ;
}
@ -331,7 +329,7 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS
}
public static void download ( String durl , String fileName ) throws Exception {
public static void download ( String durl , String fileName ) throws Exception {
//定义一个URL对象,就是你想下载的图片的URL地址
URL url = new URL ( durl ) ;
//打开连接
@ -353,6 +351,7 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS
//关闭输出流,释放资源
outStream . close ( ) ;
}
public static byte [ ] readInputStream ( InputStream inStream ) throws Exception {
ByteArrayOutputStream outStream = new ByteArrayOutputStream ( ) ;
//创建一个Buffer字符串
@ -418,16 +417,16 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS
@Override
public EnterpriseInformation paresEnterpriseCode ( String url ) throws Exception {
log . info ( "获取市监地址,地址信息:{}" , url ) ;
if ( StringUtils . isEmpty ( url ) ) {
log . info ( "获取市监地址,地址为空:{}" , url ) ;
log . info ( "获取市监地址,地址信息:{}" , url ) ;
if ( StringUtils . isEmpty ( url ) ) {
log . info ( "获取市监地址,地址为空:{}" , url ) ;
return null ;
}
StringBuffer sb = new StringBuffer ( url ) ;
StringBuffer replace = sb . replace ( 7 , 39 , sjView ) ;
//爬取页面统一信用代码
String s = CrawlerUtil . getCreditCode ( url ) ;
if ( StringUtils . isNotEmpty ( s ) ) {
if ( StringUtils . isNotEmpty ( s ) ) {
// EnterpriseInformation enterpriseInformation =
// enterpriseInformationMapper.selectEnterpriseInformationByNum(s);
EnterpriseInformation enterpriseInformation = ssztJbxx110497Service . selectSsztJbxx110497ByCode ( s ) ;
@ -435,5 +434,89 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS
}
return null ;
}
@Override
public List < StatisticsIndicator > enterpriseInformationAllListToQY ( SearchType searchType ) {
List < StatisticsIndicator > statisticsIndicatorList = new ArrayList < > ( ) ;
EnterpriseInformation enterpriseInformation = new EnterpriseInformation ( ) ;
List < String > qyNameList = new ArrayList < > ( ) ;
if ( searchType . getQy ( ) ! = null & & ! "" . equals ( searchType . getQy ( ) ) ) {
String qyName = dictDataMapper . selectDictLabel ( "address_type" , searchType . getQy ( ) ) ;
if ( searchType . getJd ( ) ! = null & & ! "" . equals ( searchType . getJd ( ) ) ) {
String jdName = dictDataMapper . selectDictLabel ( searchType . getQy ( ) , searchType . getJd ( ) ) ;
enterpriseInformation . setJd ( jdName ) ;
}
enterpriseInformation . setQy ( qyName ) ;
qyNameList . add ( qyName ) ;
} else {
List < DictData > dictDataListQY = dictDataMapper . selectDictDataByType ( "address_type" ) ;
for ( DictData dictData : dictDataListQY ) {
qyNameList . add ( dictData . getDictLabel ( ) ) ;
}
}
List < EnterpriseInformation > enterpriseInformationList = enterpriseInformationMapper . selectEnterpriseInformationList1 ( enterpriseInformation ) ;
for ( String qy : qyNameList ) {
StatisticsIndicator s = new StatisticsIndicator ( ) ;
System . out . println ( qy . substring ( 0 , qy . indexOf ( "区" ) ) ) ;
List < EnterpriseInformation > qyList = enterpriseInformationList . stream ( ) . filter ( item - > item . getEnterpriseAddress ( ) . startsWith ( "深圳市" + qy . substring ( 0 , qy . indexOf ( "区" ) ) + "区" ) | | item . getEnterpriseAddress ( ) . startsWith ( "深圳市" + qy . substring ( 0 , qy . indexOf ( "区" ) ) + "新区" ) ) . collect ( Collectors . toList ( ) ) ;
List < EnterpriseInformation > existList = qyList . stream ( ) . filter ( item - > item . getIsDelete ( ) = = 0 ) . collect ( Collectors . toList ( ) ) ;
List < EnterpriseInformation > logoutList = qyList . stream ( ) . filter ( item - > item . getIsDelete ( ) = = 1 ) . collect ( Collectors . toList ( ) ) ;
s . setName ( qy ) ;
s . setTotalNumber ( qyList . size ( ) ) ;
s . setNumInt ( existList . size ( ) ) ;
s . setValue ( logoutList . size ( ) ) ;
statisticsIndicatorList . add ( s ) ;
enterpriseInformationList = enterpriseInformationList . stream ( ) . filter ( item - > ! item . getEnterpriseAddress ( ) . startsWith ( "深圳市" + qy . substring ( 0 , qy . indexOf ( "区" ) ) + "区" ) & & ! item . getEnterpriseAddress ( ) . startsWith ( "深圳市" + qy . substring ( 0 , qy . indexOf ( "区" ) ) + "新区" ) ) . collect ( Collectors . toList ( ) ) ;
}
if ( enterpriseInformationList . size ( ) > 0 ) {
List < EnterpriseInformation > existList = enterpriseInformationList . stream ( ) . filter ( item - > item . getIsDelete ( ) = = 0 ) . collect ( Collectors . toList ( ) ) ;
List < EnterpriseInformation > logoutList = enterpriseInformationList . stream ( ) . filter ( item - > item . getIsDelete ( ) = = 1 ) . collect ( Collectors . toList ( ) ) ;
StatisticsIndicator s = new StatisticsIndicator ( ) ;
s . setName ( "其他" ) ;
s . setTotalNumber ( enterpriseInformationList . size ( ) ) ;
s . setNumInt ( existList . size ( ) ) ;
s . setValue ( logoutList . size ( ) ) ;
statisticsIndicatorList . add ( s ) ;
}
return statisticsIndicatorList ;
}
@Override
public List < StatisticsIndicator > enterpriseInformationAllListToJD ( SearchType searchType ) {
List < StatisticsIndicator > statisticsIndicatorList = new ArrayList < > ( ) ;
EnterpriseInformation enterpriseInformation = new EnterpriseInformation ( ) ;
enterpriseInformation . setQy ( searchType . getName ( ) ) ;
List < EnterpriseInformation > enterpriseInformationList = enterpriseInformationMapper . selectEnterpriseInformationList1 ( enterpriseInformation ) ;
String qyName = searchType . getName ( ) ;
DictData dictData = new DictData ( ) ;
dictData . setDictType ( "address_type" ) ;
dictData . setDictLabel ( qyName ) ;
DictData dictDataQY = dictDataMapper . selectDictData ( dictData ) ;
List < DictData > dictDataListJD = dictDataMapper . selectDictDataByType ( dictDataQY . getDictValue ( ) ) ;
for ( DictData d : dictDataListJD ) {
String jdName = d . getDictLabel ( ) ;
StatisticsIndicator s = new StatisticsIndicator ( ) ;
List < EnterpriseInformation > jdList = enterpriseInformationList . stream ( ) . filter ( item - > item . getEnterpriseAddress ( ) . startsWith ( "深圳市" + qyName . substring ( 0 , qyName . indexOf ( "区" ) ) + "区" + jdName ) | | item . getEnterpriseAddress ( ) . startsWith ( "深圳市" + qyName . substring ( 0 , qyName . indexOf ( "区" ) ) + "新区" + jdName ) ) . collect ( Collectors . toList ( ) ) ;
List < EnterpriseInformation > existList = jdList . stream ( ) . filter ( item - > item . getIsDelete ( ) = = 0 ) . collect ( Collectors . toList ( ) ) ;
List < EnterpriseInformation > logoutList = jdList . stream ( ) . filter ( item - > item . getIsDelete ( ) = = 1 ) . collect ( Collectors . toList ( ) ) ;
s . setName ( jdName ) ;
s . setAddress ( qyName ) ;
s . setTotalNumber ( jdList . size ( ) ) ;
s . setNumInt ( existList . size ( ) ) ;
s . setValue ( logoutList . size ( ) ) ;
statisticsIndicatorList . add ( s ) ;
enterpriseInformationList = enterpriseInformationList . stream ( ) . filter ( item - > ! item . getEnterpriseAddress ( ) . startsWith ( "深圳市" + qyName . substring ( 0 , qyName . indexOf ( "区" ) ) + "区" + jdName ) & & ! item . getEnterpriseAddress ( ) . startsWith ( "深圳市" + qyName . substring ( 0 , qyName . indexOf ( "区" ) ) + "新区" + jdName ) ) . collect ( Collectors . toList ( ) ) ;
}
if ( enterpriseInformationList . size ( ) > 0 ) {
StatisticsIndicator s = new StatisticsIndicator ( ) ;
List < EnterpriseInformation > existList = enterpriseInformationList . stream ( ) . filter ( item - > item . getIsDelete ( ) = = 0 ) . collect ( Collectors . toList ( ) ) ;
List < EnterpriseInformation > logoutList = enterpriseInformationList . stream ( ) . filter ( item - > item . getIsDelete ( ) = = 1 ) . collect ( Collectors . toList ( ) ) ;
s . setAddress ( qyName ) ;
s . setTotalNumber ( enterpriseInformationList . size ( ) ) ;
s . setNumInt ( existList . size ( ) ) ;
s . setValue ( logoutList . size ( ) ) ;
statisticsIndicatorList . add ( s ) ;
}
return statisticsIndicatorList ;
}
}