Browse Source

开发涉企行政检查数量指标项统计,同比环比以及总数

v4
chenrui 2 years ago
parent
commit
d35b83a671
  1. 18
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/controller/StatisticalPanelController.java
  2. 23
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/domain/StatisticsIndicatorPart.java
  3. 14
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/StatisticalPaneService.java
  4. 147
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/StatisticalPaneServiceImpl.java

18
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/controller/StatisticalPanelController.java

@ -87,5 +87,23 @@ public class StatisticalPanelController extends BaseController {
public ZDResponse complaint(StatisticsIndicatorPart statisticsIndicatorPart){ public ZDResponse complaint(StatisticsIndicatorPart statisticsIndicatorPart){
return ZDResponse.success("成功",statisticalPaneService.complaint(statisticsIndicatorPart)); return ZDResponse.success("成功",statisticalPaneService.complaint(statisticsIndicatorPart));
} }
/*------------------------------------------综合分析-新版--------------------------------*/
@GetMapping("/registrationNew")
@ResponseBody
public ZDResponse registrationNew(StatisticsIndicatorPart statisticsIndicatorPart){
return ZDResponse.success("涉企检查数据统计",statisticalPaneService.registrationNew(statisticsIndicatorPart));
}
} }

23
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/domain/StatisticsIndicatorPart.java

@ -10,6 +10,14 @@ public class StatisticsIndicatorPart extends BaseDomain {
private Integer number; private Integer number;
private Integer huan; private Integer huan;
private Integer tong; private Integer tong;
/**
* 同比-新字段
*/
private Double tongValue;
/**
* 环比-新字段
*/
private Double huanValue;
private Integer complaint; private Integer complaint;
List<StatisticsIndicatorPart> statisticsIndicatorPartList; List<StatisticsIndicatorPart> statisticsIndicatorPartList;
@ -157,4 +165,19 @@ public class StatisticsIndicatorPart extends BaseDomain {
this.endTime = endTime; this.endTime = endTime;
} }
public Double getTongValue() {
return tongValue;
}
public void setTongValue(Double tongValue) {
this.tongValue = tongValue;
}
public Double getHuanValue() {
return huanValue;
}
public void setHuanValue(Double huanValue) {
this.huanValue = huanValue;
}
} }

14
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/StatisticalPaneService.java

@ -28,4 +28,18 @@ public interface StatisticalPaneService {
*/ */
StatisticsIndicatorPart statisticProgram(StatisticsIndicatorPart statisticsIndicatorPart); StatisticsIndicatorPart statisticProgram(StatisticsIndicatorPart statisticsIndicatorPart);
/*------------------------------------------综合分析-新版--------------------------------*/
/**
* 统计涉企检查数量-新版
* @param statisticsIndicatorPart
* @return
*/
StatisticsIndicatorPart registrationNew(StatisticsIndicatorPart statisticsIndicatorPart);
} }

147
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/StatisticalPaneServiceImpl.java

@ -12,13 +12,18 @@ import com.zdxt.code.domain.*;
import com.zdxt.code.domain.dto.StatisticalPanelDto; import com.zdxt.code.domain.dto.StatisticalPanelDto;
import com.zdxt.code.mapper.StatisticalPanelMapper; import com.zdxt.code.mapper.StatisticalPanelMapper;
import com.zdxt.code.service.*; import com.zdxt.code.service.*;
import com.zdxt.common.annotation.DataScope;
import com.zdxt.domain.auth.Dept; import com.zdxt.domain.auth.Dept;
import com.zdxt.domain.auth.User; import com.zdxt.domain.auth.User;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters; import java.time.temporal.TemporalAdjusters;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -67,6 +72,7 @@ public class StatisticalPaneServiceImpl implements StatisticalPaneService {
*/ */
@Override @Override
public StatisticsIndicatorPart enterprise(StatisticsIndicatorPart statisticsIndicatorPart){ public StatisticsIndicatorPart enterprise(StatisticsIndicatorPart statisticsIndicatorPart){
StatisticsIndicatorPart sNow=nowDataMake(statisticsIndicatorPart); StatisticsIndicatorPart sNow=nowDataMake(statisticsIndicatorPart);
StatisticsIndicatorPart sLast=lastDataMake(statisticsIndicatorPart,sNow.getBeginTime()); StatisticsIndicatorPart sLast=lastDataMake(statisticsIndicatorPart,sNow.getBeginTime());
EnterpriseInformation enterpriseNow=new EnterpriseInformation(); EnterpriseInformation enterpriseNow=new EnterpriseInformation();
@ -75,6 +81,7 @@ public class StatisticalPaneServiceImpl implements StatisticalPaneService {
enterpriseNow.setEndTime(sNow.getEndTime()); enterpriseNow.setEndTime(sNow.getEndTime());
enterpriseLast.setBeginTime(sLast.getBeginTime()); enterpriseLast.setBeginTime(sLast.getBeginTime());
enterpriseLast.setEndTime(sLast.getEndTime()); enterpriseLast.setEndTime(sLast.getEndTime());
List<EnterpriseInformation> enterpriseNowList = iEnterpriseInformationService.selectEnterpriseInformationList1(enterpriseNow); List<EnterpriseInformation> enterpriseNowList = iEnterpriseInformationService.selectEnterpriseInformationList1(enterpriseNow);
List<EnterpriseInformation> enterpriseLastList = iEnterpriseInformationService.selectEnterpriseInformationList1(enterpriseLast); List<EnterpriseInformation> enterpriseLastList = iEnterpriseInformationService.selectEnterpriseInformationList1(enterpriseLast);
List<EnterpriseInformation> existListNow = enterpriseNowList.stream().filter(item -> item.getIsUnsubscribe() == 0).collect(Collectors.toList()); List<EnterpriseInformation> existListNow = enterpriseNowList.stream().filter(item -> item.getIsUnsubscribe() == 0).collect(Collectors.toList());
@ -370,6 +377,52 @@ public class StatisticalPaneServiceImpl implements StatisticalPaneService {
return statisticsIndicatorPartResult; 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的形式 * 当前时间处理--转换成beginTime和endTime的形式
@ -417,8 +470,10 @@ public class StatisticalPaneServiceImpl implements StatisticalPaneService {
} }
return statisticsIndicatorPart; return statisticsIndicatorPart;
} }
/** /**
* 上一时间处理--转换成beginTime和endTime的形式 * 上一时间处理同比时间--转换成beginTime和endTime的形式
*/ */
public StatisticsIndicatorPart lastDataMake(StatisticsIndicatorPart sip,String nowBeginData){ public StatisticsIndicatorPart lastDataMake(StatisticsIndicatorPart sip,String nowBeginData){
DateTimeFormatter str3=DateTimeFormatter.ofPattern("MM"); DateTimeFormatter str3=DateTimeFormatter.ofPattern("MM");
@ -445,6 +500,78 @@ public class StatisticalPaneServiceImpl implements StatisticalPaneService {
} }
return statisticsIndicatorPart; 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(){ public String takeDeptId(){
/*//获取该帐号执法证件号 /*//获取该帐号执法证件号
String lawCertificateNum=userApi.getCurrentUser().getLawCertificateNum(); 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;
}
} }

Loading…
Cancel
Save