@ -7,6 +7,8 @@ import cn.hutool.core.util.ObjectUtil;
@@ -7,6 +7,8 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil ;
import com.alibaba.fastjson.JSON ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import jnpf.base.DictionaryDataApi ;
import jnpf.base.entity.DictionaryDataEntity ;
import jnpf.entity.Bidding_project_statisticsEntity ;
import jnpf.exception.DataException ;
import jnpf.model.dto.IndicatorStatisticsDto ;
@ -27,6 +29,7 @@ import java.time.format.DateTimeFormatter;
@@ -27,6 +29,7 @@ import java.time.format.DateTimeFormatter;
import java.util.ArrayList ;
import java.util.List ;
import java.util.Optional ;
import java.util.stream.Collectors ;
@Service
@AllArgsConstructor
@ -35,6 +38,7 @@ public class IndicatorStatisticsServiceImpl implements IndicatorStatisticsServic
@@ -35,6 +38,7 @@ public class IndicatorStatisticsServiceImpl implements IndicatorStatisticsServic
private final BiddingProjectSubscribeService biddingProjectSubscribeService ;
private final CustomAuthService customAuthService ;
private final UserProvider userProvider ;
private final DictionaryDataApi dictionaryDataApi ;
@Override
@ -100,7 +104,11 @@ public class IndicatorStatisticsServiceImpl implements IndicatorStatisticsServic
@@ -100,7 +104,11 @@ public class IndicatorStatisticsServiceImpl implements IndicatorStatisticsServic
}
LocalDateTime month = LocalDateTimeUtil . parse ( param . getCorresponding ( ) , "yyyy-MM" ) ;
YearMonth yearMonth = YearMonth . from ( month ) ;
for ( int day = 1 ; day < = yearMonth . lengthOfMonth ( ) ; day + + ) {
int i = yearMonth . lengthOfMonth ( ) ;
if ( LocalDateTimeUtil . parse ( LocalDateTimeUtil . format ( LocalDateTime . now ( ) , "yyyy-MM" ) , "yyyy-MM" ) . isEqual ( LocalDateTimeUtil . parse ( param . getCorresponding ( ) , "yyyy-MM" ) ) ) {
i = LocalDateTime . now ( ) . getDayOfMonth ( ) ;
}
for ( int day = 1 ; day < = i ; day + + ) {
IndicatorStatisticsDto . Indicator indicator = new IndicatorStatisticsDto . Indicator ( ) ;
indicator . setYData ( "0" ) ;
// 创建代表该日期的LocalDate对象
@ -112,6 +120,7 @@ public class IndicatorStatisticsServiceImpl implements IndicatorStatisticsServic
@@ -112,6 +120,7 @@ public class IndicatorStatisticsServiceImpl implements IndicatorStatisticsServic
}
break ;
case "2" :
int value = LocalDateTime . now ( ) . getMonth ( ) . getValue ( ) ;
if ( StrUtil . isBlank ( param . getCorresponding ( ) ) ) {
String yyyy = LocalDateTimeUtil . format ( LocalDateTime . now ( ) , "yyyy" ) ;
param . setCorresponding ( yyyy ) ;
@ -120,11 +129,14 @@ public class IndicatorStatisticsServiceImpl implements IndicatorStatisticsServic
@@ -120,11 +129,14 @@ public class IndicatorStatisticsServiceImpl implements IndicatorStatisticsServic
//校验时间格式
try {
response . setCorresponding ( LocalDateTimeUtil . parse ( param . getCorresponding ( ) , "yyyy" ) ) ;
if ( LocalDateTime . now ( ) . getYear ( ) > LocalDateTimeUtil . parse ( param . getCorresponding ( ) , "yyyy" ) . getYear ( ) ) {
value = 12 ;
}
} catch ( Exception e ) {
throw new DataException ( "dataTime parse error, must be yyyy" ) ;
}
}
for ( int monthCount = 1 ; monthCount < = 12 ; monthCount + + ) {
for ( int monthCount = 1 ; monthCount < = value ; monthCount + + ) {
IndicatorStatisticsDto . Indicator indicator = new IndicatorStatisticsDto . Indicator ( ) ;
indicator . setYData ( "0" ) ;
String monthString = String . format ( "%02d" , monthCount ) ;
@ -149,10 +161,65 @@ public class IndicatorStatisticsServiceImpl implements IndicatorStatisticsServic
@@ -149,10 +161,65 @@ public class IndicatorStatisticsServiceImpl implements IndicatorStatisticsServic
}
assert queryWhere ! = null ;
List < IndicatorStatisticsDto . MoneyAndProjectsNumberChild > dataList = biddingProjectSubscribeService . moneyAndProjectsNumber ( param , queryWhere . getParamNameValuePairs ( ) , queryWhere . getSqlSegment ( ) . replace ( "paramNameValuePairs." , "" ) ) ;
checkMoneyAndProjectsNumberResult ( param , dataList ) ;
response . setDataList ( dataList ) ;
return response ;
}
private void checkMoneyAndProjectsNumberResult ( IndicatorStatisticsDto . MoneyAndProjectsNumberParam param , List < IndicatorStatisticsDto . MoneyAndProjectsNumberChild > dataList ) {
// <if test="param.classificationType=='2'.toString()">
// count(organizational_form) projectsNumber,
// (select f_full_name from base_dictionary_data where f_dictionary_type_id='539393647729185989' and f_en_code=main.organizational_form limit 1) yName
// </if>
// <if test="param.classificationType=='3'.toString()">
// count(Item_classification) projectsNumber,
// (select f_full_name from base_dictionary_data where f_dictionary_type_id='539390743437907141' and f_en_code=main.item_classification limit 1) yName
// </if>
// <if test="param.classificationType=='4'.toString()">
// count(bidding_method) projectsNumber,
// (select f_full_name from base_dictionary_data where f_dictionary_type_id='539394095383057605' and f_en_code=main.bidding_method limit 1) yName
// </if>
String classificationType = param . getClassificationType ( ) ;
List < String > oldNameList = dataList . stream ( ) . map ( IndicatorStatisticsDto . MoneyAndProjectsNumberChild : : getYName ) . collect ( Collectors . toList ( ) ) ;
List < String > newNameList = new ArrayList < > ( ) ;
switch ( classificationType ) {
case "1" :
break ;
case "2" :
newNameList = dictionaryDataApi . getList ( "539393647729185989" )
. stream ( )
. map ( DictionaryDataEntity : : getFullName )
. filter ( fullName - > ! oldNameList . contains ( fullName ) )
. collect ( Collectors . toList ( ) ) ;
break ;
case "3" :
newNameList = dictionaryDataApi . getList ( "539390743437907141" )
. stream ( )
. map ( DictionaryDataEntity : : getFullName )
. filter ( fullName - > ! oldNameList . contains ( fullName ) )
. collect ( Collectors . toList ( ) ) ;
break ;
case "4" :
newNameList = dictionaryDataApi . getList ( "539394095383057605" )
. stream ( )
. map ( DictionaryDataEntity : : getFullName )
. filter ( fullName - > ! oldNameList . contains ( fullName ) )
. collect ( Collectors . toList ( ) ) ;
break ;
}
if ( CollectionUtil . isEmpty ( newNameList ) ) {
return ;
}
for ( String name : newNameList ) {
IndicatorStatisticsDto . MoneyAndProjectsNumberChild data = new IndicatorStatisticsDto . MoneyAndProjectsNumberChild ( ) ;
data . setYName ( name ) ;
data . setProjectsNumber ( "0" ) ;
data . setMoney ( "0.0" ) ;
dataList . add ( data ) ;
}
}
private IndicatorStatisticsDto . MoneyAndProjectsNumberResponse checkMoneyAndProjectsNumberParam ( IndicatorStatisticsDto . MoneyAndProjectsNumberParam param ) {
IndicatorStatisticsDto . MoneyAndProjectsNumberResponse response = new IndicatorStatisticsDto . MoneyAndProjectsNumberResponse ( ) ;
if ( StrUtil . isBlank ( param . getMenuId ( ) ) ) {