|
|
|
@ -12,13 +12,18 @@ import com.zdxt.code.domain.*; |
|
|
|
import com.zdxt.code.domain.dto.StatisticalPanelDto; |
|
|
|
import com.zdxt.code.mapper.StatisticalPanelMapper; |
|
|
|
import com.zdxt.code.service.*; |
|
|
|
import com.zdxt.common.annotation.DataScope; |
|
|
|
import com.zdxt.domain.auth.Dept; |
|
|
|
import com.zdxt.domain.auth.User; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.text.DecimalFormat; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.temporal.ChronoUnit; |
|
|
|
import java.time.temporal.TemporalAdjusters; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
@ -67,6 +72,7 @@ public class StatisticalPaneServiceImpl implements StatisticalPaneService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public StatisticsIndicatorPart enterprise(StatisticsIndicatorPart statisticsIndicatorPart){ |
|
|
|
|
|
|
|
StatisticsIndicatorPart sNow=nowDataMake(statisticsIndicatorPart); |
|
|
|
StatisticsIndicatorPart sLast=lastDataMake(statisticsIndicatorPart,sNow.getBeginTime()); |
|
|
|
EnterpriseInformation enterpriseNow=new EnterpriseInformation(); |
|
|
|
@ -75,6 +81,7 @@ public class StatisticalPaneServiceImpl implements StatisticalPaneService { |
|
|
|
enterpriseNow.setEndTime(sNow.getEndTime()); |
|
|
|
enterpriseLast.setBeginTime(sLast.getBeginTime()); |
|
|
|
enterpriseLast.setEndTime(sLast.getEndTime()); |
|
|
|
|
|
|
|
List<EnterpriseInformation> enterpriseNowList = iEnterpriseInformationService.selectEnterpriseInformationList1(enterpriseNow); |
|
|
|
List<EnterpriseInformation> enterpriseLastList = iEnterpriseInformationService.selectEnterpriseInformationList1(enterpriseLast); |
|
|
|
List<EnterpriseInformation> existListNow = enterpriseNowList.stream().filter(item -> item.getIsUnsubscribe() == 0).collect(Collectors.toList()); |
|
|
|
@ -370,6 +377,52 @@ public class StatisticalPaneServiceImpl implements StatisticalPaneService { |
|
|
|
return statisticsIndicatorPartResult; |
|
|
|
} |
|
|
|
|
|
|
|
@DataScope |
|
|
|
@Override |
|
|
|
public StatisticsIndicatorPart registrationNew(StatisticsIndicatorPart statisticsIndicatorPart) { |
|
|
|
//获取当前用户所在执法部门ID
|
|
|
|
String deptId = takeDeptId(); |
|
|
|
//获取当前部门执法数据
|
|
|
|
//获取当前时间
|
|
|
|
StatisticsIndicatorPart sNow = nowDataMake(statisticsIndicatorPart); |
|
|
|
//获取当前时间的同比时间
|
|
|
|
StatisticsIndicatorPart sLast = lastDataMake(statisticsIndicatorPart,sNow.getBeginTime()); |
|
|
|
//获取当前时间的环比时间
|
|
|
|
StatisticsIndicatorPart sLastQoQ = lastDataMakeQoQ(statisticsIndicatorPart); |
|
|
|
|
|
|
|
//当前搜索时间
|
|
|
|
EnforcementRegistration enforcementRegistrationNow = new EnforcementRegistration(); |
|
|
|
enforcementRegistrationNow.setBeginTime(sNow.getBeginTime()); |
|
|
|
enforcementRegistrationNow.setEndTime(sNow.getEndTime()); |
|
|
|
//当前时间的同比时间
|
|
|
|
EnforcementRegistration enforcementRegistrationLast = new EnforcementRegistration(); |
|
|
|
enforcementRegistrationLast.setBeginTime(sLast.getBeginTime()); |
|
|
|
enforcementRegistrationLast.setEndTime(sLast.getEndTime()); |
|
|
|
//当前时间环比时间
|
|
|
|
EnforcementRegistration enforcementRegistrationLastQoQ = new EnforcementRegistration(); |
|
|
|
enforcementRegistrationLastQoQ.setBeginTime(sLastQoQ.getBeginTime()); |
|
|
|
enforcementRegistrationLastQoQ.setEndTime(sLastQoQ.getEndTime()); |
|
|
|
|
|
|
|
//根据时间规则获取同一时间段内的数据
|
|
|
|
List<EnforcementRegistration> now = enforcementRegistrationService.selectEnforcementRegistrationList1(enforcementRegistrationNow); |
|
|
|
List<EnforcementRegistration> last = enforcementRegistrationService.selectEnforcementRegistrationList1(enforcementRegistrationLast); |
|
|
|
List<EnforcementRegistration> lastQoQ = enforcementRegistrationService.selectEnforcementRegistrationList1(enforcementRegistrationLastQoQ); |
|
|
|
|
|
|
|
//计算同比
|
|
|
|
double tong = calculateYearOnYearGrowth(last.size(), now.size()); |
|
|
|
//计算环比
|
|
|
|
double huan = calculateYearOnYearGrowth(lastQoQ.size(), now.size()); |
|
|
|
|
|
|
|
//定义返回DTO
|
|
|
|
StatisticsIndicatorPart statisticsIndicatorPart1 = new StatisticsIndicatorPart(); |
|
|
|
statisticsIndicatorPart1.setTongValue(tong); |
|
|
|
statisticsIndicatorPart1.setHuanValue(huan); |
|
|
|
statisticsIndicatorPart1.setTotal(now.size()); |
|
|
|
|
|
|
|
|
|
|
|
return statisticsIndicatorPart1; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 当前时间处理--转换成beginTime和endTime的形式 |
|
|
|
@ -387,8 +440,8 @@ public class StatisticalPaneServiceImpl implements StatisticalPaneService { |
|
|
|
statisticsIndicatorPart.setBeginTime(str.format(beginTime)); |
|
|
|
statisticsIndicatorPart.setEndTime(str.format(endTime)); |
|
|
|
}else if(sip.getQuarter()!=null&&!"".equals(sip.getQuarter())){ |
|
|
|
LocalDate beginTime=LocalDate.now(); |
|
|
|
LocalDate endTime=LocalDate.now(); |
|
|
|
LocalDate beginTime = LocalDate.now(); |
|
|
|
LocalDate endTime = LocalDate.now(); |
|
|
|
switch (sip.getQuarter()) { |
|
|
|
case 1: |
|
|
|
beginTime = localDate.withYear(Integer.valueOf(sip.getYear())).withMonth(1).withDayOfMonth(1); |
|
|
|
@ -417,8 +470,10 @@ public class StatisticalPaneServiceImpl implements StatisticalPaneService { |
|
|
|
} |
|
|
|
return statisticsIndicatorPart; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 上一时间处理--转换成beginTime和endTime的形式 |
|
|
|
* 上一时间处理(同比时间)--转换成beginTime和endTime的形式 |
|
|
|
*/ |
|
|
|
public StatisticsIndicatorPart lastDataMake(StatisticsIndicatorPart sip,String nowBeginData){ |
|
|
|
DateTimeFormatter str3=DateTimeFormatter.ofPattern("MM"); |
|
|
|
@ -445,6 +500,78 @@ public class StatisticalPaneServiceImpl implements StatisticalPaneService { |
|
|
|
} |
|
|
|
return statisticsIndicatorPart; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 上一时间处理(环比时间)--转换成beginTime和endTime的形式 |
|
|
|
*/ |
|
|
|
public StatisticsIndicatorPart lastDataMakeQoQ(StatisticsIndicatorPart sip){ |
|
|
|
/*DateTimeFormatter str3=DateTimeFormatter.ofPattern("MM"); |
|
|
|
DateTimeFormatter str = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
|
|
|
LocalDate localDate = LocalDate.parse(nowBeginData, str); |
|
|
|
LocalDate previousYearDate = localDate.minus(1, ChronoUnit.YEARS); |
|
|
|
StatisticsIndicatorPart statisticsIndicatorPart=new StatisticsIndicatorPart(); |
|
|
|
if(sip.getMonth()!=null&&!"".equals(sip.getMonth())) { |
|
|
|
LocalDate beginTime=previousYearDate.minusMonths(1).withDayOfMonth(1); |
|
|
|
LocalDate endTime = previousYearDate.minusMonths(1).with(TemporalAdjusters.lastDayOfMonth()); |
|
|
|
statisticsIndicatorPart.setBeginTime(str.format(beginTime)); |
|
|
|
statisticsIndicatorPart.setEndTime(str.format(endTime)); |
|
|
|
}else if(sip.getQuarter()!=null&&!"".equals(sip.getQuarter())){ |
|
|
|
previousYearDate = previousYearDate.minusMonths(3); |
|
|
|
int quarter=(int)Math.ceil(Double.valueOf(str3.format(previousYearDate))/3); |
|
|
|
LocalDate beginTime = previousYearDate.withMonth(quarter*3-2).withDayOfMonth(1); |
|
|
|
LocalDate endTime=previousYearDate.withMonth(quarter*3).with(TemporalAdjusters.lastDayOfMonth()); |
|
|
|
statisticsIndicatorPart.setBeginTime(str.format(beginTime)); |
|
|
|
statisticsIndicatorPart.setEndTime(str.format(endTime)); |
|
|
|
}else { |
|
|
|
LocalDate beginTime=previousYearDate.minusYears(1).withMonth(1).withDayOfMonth(1); |
|
|
|
LocalDate endTime=previousYearDate.minusYears(1).withMonth(12).with(TemporalAdjusters.lastDayOfMonth()); |
|
|
|
statisticsIndicatorPart.setBeginTime(str.format(beginTime)); |
|
|
|
statisticsIndicatorPart.setEndTime(str.format(endTime)); |
|
|
|
}*/ |
|
|
|
|
|
|
|
// LocalDate previousYearDate = localDate.minus(1, ChronoUnit.YEARS);
|
|
|
|
LocalDate localDate = LocalDate.now(); |
|
|
|
localDate = localDate.minus(1, ChronoUnit.YEARS); |
|
|
|
DateTimeFormatter str=DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
|
|
|
StatisticsIndicatorPart statisticsIndicatorPart=new StatisticsIndicatorPart(); |
|
|
|
if(sip.getYear()==null||"".equals(sip.getYear())){ |
|
|
|
sip.setYear(localDate.getYear()+""); |
|
|
|
} |
|
|
|
if(sip.getMonth()!=null&&!"".equals(sip.getMonth())) { |
|
|
|
LocalDate beginTime = localDate.withYear(Integer.valueOf(localDate.getYear())).withMonth(Integer.valueOf(localDate.getDayOfMonth())).withDayOfMonth(1); |
|
|
|
LocalDate endTime = beginTime.with(TemporalAdjusters.lastDayOfMonth()); |
|
|
|
statisticsIndicatorPart.setBeginTime(str.format(beginTime)); |
|
|
|
statisticsIndicatorPart.setEndTime(str.format(endTime)); |
|
|
|
}else if(sip.getQuarter()!=null&&!"".equals(sip.getQuarter())){ |
|
|
|
LocalDate beginTime = localDate; |
|
|
|
LocalDate endTime = localDate; |
|
|
|
switch (sip.getQuarter()) { |
|
|
|
case 1: |
|
|
|
beginTime = localDate.withYear(Integer.valueOf(localDate.getYear())).withMonth(1).withDayOfMonth(1); |
|
|
|
endTime = beginTime.withMonth(3).with(TemporalAdjusters.lastDayOfMonth()); |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
beginTime = localDate.withYear(Integer.valueOf(localDate.getYear())).withMonth(4).withDayOfMonth(1); |
|
|
|
endTime = beginTime.withMonth(6).with(TemporalAdjusters.lastDayOfMonth()); |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
beginTime = localDate.withYear(Integer.valueOf(localDate.getYear())).withMonth(7).withDayOfMonth(1); |
|
|
|
endTime = beginTime.withMonth(9).with(TemporalAdjusters.lastDayOfMonth()); |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
beginTime = localDate.withYear(Integer.valueOf(localDate.getYear())).withMonth(10).withDayOfMonth(1); |
|
|
|
endTime = beginTime.withMonth(12).with(TemporalAdjusters.lastDayOfMonth()); |
|
|
|
break; |
|
|
|
} |
|
|
|
statisticsIndicatorPart.setBeginTime(str.format(beginTime)); |
|
|
|
statisticsIndicatorPart.setEndTime(str.format(endTime)); |
|
|
|
}else { |
|
|
|
LocalDate beginTime=localDate.withYear(Integer.valueOf(localDate.getYear())).withMonth(1).withDayOfMonth(1); |
|
|
|
LocalDate endTime = localDate.withYear(Integer.valueOf(localDate.getYear())).withMonth(12).with(TemporalAdjusters.lastDayOfMonth()); |
|
|
|
statisticsIndicatorPart.setBeginTime(str.format(beginTime)); |
|
|
|
statisticsIndicatorPart.setEndTime(str.format(endTime)); |
|
|
|
} |
|
|
|
return statisticsIndicatorPart; |
|
|
|
} |
|
|
|
public String takeDeptId(){ |
|
|
|
/*//获取该帐号执法证件号
|
|
|
|
String lawCertificateNum=userApi.getCurrentUser().getLawCertificateNum(); |
|
|
|
@ -486,4 +613,22 @@ public class StatisticalPaneServiceImpl implements StatisticalPaneService { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 计算同比增长百分比 |
|
|
|
* @param baseValue 基准值 |
|
|
|
* @param currentValue 当前值 |
|
|
|
* @return 同比增长百分比 |
|
|
|
*/ |
|
|
|
public static double calculateYearOnYearGrowth(double baseValue, double currentValue) { |
|
|
|
if (baseValue == 0) { |
|
|
|
// 如果基准值为0,则无法计算同比增长,可以返回一个特定的值,例如Double.NaN或者一个错误消息
|
|
|
|
return 0.00; // 或者抛出异常
|
|
|
|
} |
|
|
|
|
|
|
|
double growth = (currentValue - baseValue) / baseValue * 100; |
|
|
|
BigDecimal bd = new BigDecimal(growth); |
|
|
|
double v = bd.setScale(2, RoundingMode.HALF_UP).doubleValue(); |
|
|
|
return v; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|