2 İşlemeler 019f5630f9 ... bc76a41365

Yazar SHA1 Mesaj Tarih
  ljx bc76a41365 Merge remote-tracking branch 'origin/master' 1 ay önce
  ljx 004f9756f3 企业效益监测评估接口 1 ay önce

+ 29 - 0
enteprise-admin/src/main/java/com/enteprise/benefit_monitor_assess/controller/BenefitMonitorAssessController.java

@@ -0,0 +1,29 @@
+package com.enteprise.benefit_monitor_assess.controller;
+
+import com.enteprise.benefit_monitor_assess.domain.BenefitMonitorAssess;
+import com.enteprise.benefit_monitor_assess.service.IBusinessMonitorAssessService;
+import com.enteprise.common.core.controller.BaseController;
+import com.enteprise.common.core.page.TableDataInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/benefit/benefit")
+public class BenefitMonitorAssessController extends BaseController {
+    @Autowired
+    private IBusinessMonitorAssessService businessMonitorAssessService;
+
+    /**
+     * 查询benefit列表
+     */
+    @PreAuthorize("@ss.hasPermi('benefit:benefit:list')")
+    @PostMapping("/list")
+    public TableDataInfo list(@RequestBody BenefitMonitorAssess benefitMonitorAssess) {
+        startPage();
+        List<BenefitMonitorAssess> list = businessMonitorAssessService.getListByBusinessMonitorAssess(benefitMonitorAssess);
+        return getDataTable(list);
+    }
+}

+ 70 - 0
enteprise-admin/src/main/java/com/enteprise/benefit_monitor_assess/domain/AvgBenefit.java

@@ -0,0 +1,70 @@
+package com.enteprise.benefit_monitor_assess.domain;
+
+import com.enteprise.common.annotation.Excel;
+import com.enteprise.common.core.domain.BaseEntity;
+
+public class AvgBenefit extends BaseEntity {
+    @Excel(name = "企业名称")
+    private String enterpriseName;
+
+
+    private Double industrialValueAvg;
+
+    private Double paidTaxAvg;
+
+    /** 行业代码 */
+    @Excel(name = "行业代码")
+    private String code;
+
+    private String year;
+
+    private String season;
+
+    public String getYear() {
+        return year;
+    }
+
+    public void setYear(String year) {
+        this.year = year;
+    }
+
+    public String getSeason() {
+        return season;
+    }
+
+    public void setSeason(String season) {
+        this.season = season;
+    }
+
+    public String getEnterpriseName() {
+        return enterpriseName;
+    }
+
+    public void setEnterpriseName(String enterpriseName) {
+        this.enterpriseName = enterpriseName;
+    }
+
+    public Double getIndustrialValueAvg() {
+        return industrialValueAvg;
+    }
+
+    public void setIndustrialValueAvg(Double industrialValueAvg) {
+        this.industrialValueAvg = industrialValueAvg;
+    }
+
+    public Double getPaidTaxAvg() {
+        return paidTaxAvg;
+    }
+
+    public void setPaidTaxAvg(Double paidTaxAvg) {
+        this.paidTaxAvg = paidTaxAvg;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+}

+ 18 - 8
enteprise-admin/src/main/java/com/enteprise/business_monitor_assess/domain/BusinessMonitorAssess.java → enteprise-admin/src/main/java/com/enteprise/benefit_monitor_assess/domain/BenefitMonitorAssess.java

@@ -1,10 +1,10 @@
-package com.enteprise.business_monitor_assess.domain;
+package com.enteprise.benefit_monitor_assess.domain;
 
 
 import com.enteprise.common.annotation.Excel;
 import com.enteprise.common.core.domain.BaseEntity;
 
-public class BusinessMonitorAssess extends BaseEntity {
+public class BenefitMonitorAssess extends BaseEntity {
     //企业ID、时间(年度)、时间(季度)、所属行业、趋势分析情况/平均水平分析情况、企业运营评估结果;
     @Excel(name = "企业名称")
     private String enterpriseName;
@@ -14,8 +14,8 @@ public class BusinessMonitorAssess extends BaseEntity {
     private String year;
 
     /** 月份 */
-    @Excel(name = "月份")
-    private String month;
+    @Excel(name = "季度")
+    private String season;
 
     /** 行业代码 */
     @Excel(name = "行业代码")
@@ -30,6 +30,8 @@ public class BusinessMonitorAssess extends BaseEntity {
     /** 运营评估 */
     @Excel(name = "运营评估")
     private String operationalEvaluate;
+    /** 评估方式*/
+    private String mode;
 
     public String getEnterpriseName() {
         return enterpriseName;
@@ -47,12 +49,12 @@ public class BusinessMonitorAssess extends BaseEntity {
         this.year = year;
     }
 
-    public String getMonth() {
-        return month;
+    public String getSeason() {
+        return season;
     }
 
-    public void setMonth(String month) {
-        this.month = month;
+    public void setSeason(String season) {
+        this.season = season;
     }
 
     public String getCode() {
@@ -86,4 +88,12 @@ public class BusinessMonitorAssess extends BaseEntity {
     public void setOperationalEvaluate(String operationalEvaluate) {
         this.operationalEvaluate = operationalEvaluate;
     }
+
+    public String getMode() {
+        return mode;
+    }
+
+    public void setMode(String mode) {
+        this.mode = mode;
+    }
 }

+ 43 - 0
enteprise-admin/src/main/java/com/enteprise/benefit_monitor_assess/domain/IndustrySummary.java

@@ -0,0 +1,43 @@
+package com.enteprise.benefit_monitor_assess.domain;
+
+import com.enteprise.common.core.domain.BaseEntity;
+
+public class IndustrySummary extends BaseEntity {
+
+
+    private Double industrialValueSum;
+
+    private Double paidTaxSum;
+
+    private int enterpriseNumber;
+
+    public IndustrySummary(double totalIndustrialValue, double totalPaidTax, int uniqueEnterpriseCount) {
+        this.industrialValueSum = totalIndustrialValue;
+        this.paidTaxSum = totalPaidTax;
+        this.enterpriseNumber = uniqueEnterpriseCount;
+    }
+
+    public Integer getEnterpriseNumber() {
+        return enterpriseNumber;
+    }
+
+    public void setEnterpriseNumber(Integer enterpriseNumber) {
+        this.enterpriseNumber = enterpriseNumber;
+    }
+
+    public Double getIndustrialValueSum() {
+        return industrialValueSum;
+    }
+
+    public void setIndustrialValueSum(Double industrialValueSum) {
+        this.industrialValueSum = industrialValueSum;
+    }
+
+    public Double getPaidTaxSum() {
+        return paidTaxSum;
+    }
+
+    public void setPaidTaxSum(Double paidTaxSum) {
+        this.paidTaxSum = paidTaxSum;
+    }
+}

+ 5 - 0
enteprise-admin/src/main/java/com/enteprise/benefit_monitor_assess/mapper/BusinessMonitorAssessMapper.java

@@ -0,0 +1,5 @@
+package com.enteprise.benefit_monitor_assess.mapper;
+
+public interface BusinessMonitorAssessMapper {
+
+}

+ 10 - 0
enteprise-admin/src/main/java/com/enteprise/benefit_monitor_assess/service/IBusinessMonitorAssessService.java

@@ -0,0 +1,10 @@
+package com.enteprise.benefit_monitor_assess.service;
+
+import com.enteprise.benefit_monitor_assess.domain.BenefitMonitorAssess;
+
+import java.util.List;
+
+public interface IBusinessMonitorAssessService {
+
+    public List<BenefitMonitorAssess> getListByBusinessMonitorAssess(BenefitMonitorAssess businessMonitorAssess);
+}

+ 367 - 0
enteprise-admin/src/main/java/com/enteprise/benefit_monitor_assess/service/impl/BusinessMonitorAssessService.java

@@ -0,0 +1,367 @@
+package com.enteprise.benefit_monitor_assess.service.impl;
+
+import com.enteprise.benefit_monitor_assess.domain.AvgBenefit;
+import com.enteprise.benefit_monitor_assess.domain.BenefitMonitorAssess;
+import com.enteprise.benefit_monitor_assess.domain.IndustrySummary;
+import com.enteprise.benefit_monitor_assess.service.IBusinessMonitorAssessService;
+import com.enteprise.industry_run.domain.EnterpriseBaseDataTotal;
+import com.enteprise.industry_run.service.IEnterpriseBaseDataTotalService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+
+@Service
+public class BusinessMonitorAssessService implements IBusinessMonitorAssessService {
+
+    @Autowired
+    IEnterpriseBaseDataTotalService service;
+
+    private static final Logger LOGGER = Logger.getLogger(BusinessMonitorAssessService.class.getName());
+    @Override
+    public List<BenefitMonitorAssess> getListByBusinessMonitorAssess(BenefitMonitorAssess businessMonitorAssess) {
+        List<BenefitMonitorAssess> list = new ArrayList<>();
+        EnterpriseBaseDataTotal dataTotal = new EnterpriseBaseDataTotal();
+        List<EnterpriseBaseDataTotal> currentDataTotal = new ArrayList<>();
+        List<EnterpriseBaseDataTotal> previousDataTotal = new ArrayList<>();
+        String year = businessMonitorAssess.getYear();
+        String season = businessMonitorAssess.getSeason();
+        //若有企业、行业过滤直接赋值进行筛选
+        dataTotal.setCode(businessMonitorAssess.getCode());
+        dataTotal.setEnterpriseName(businessMonitorAssess.getEnterpriseName());
+        //if趋势分析,获取上一个季度的工业产值、电力消耗、实缴税金、本季度实缴税金
+        if (year !=null || !year.equals("")) {
+            //精确到年份
+            if (season != null) {
+                //精确到季度
+                setDataWithYearAndSeason(year, season, dataTotal);
+                currentDataTotal = service.selectEnterpriseBaseDataTotalList(dataTotal);
+                getPreviousQuarter(businessMonitorAssess, dataTotal);
+                previousDataTotal = service.selectEnterpriseBaseDataTotalList(dataTotal);
+                //判断分析方式
+                if (businessMonitorAssess.getMode().equals("trendAnalysis")) {
+                    compareTrendAnalysis(currentDataTotal, previousDataTotal, list);
+                } else if (businessMonitorAssess.getMode().equals("avgAnalysis")) {
+                    compareAvgAnalysis(previousDataTotal, list, year, season);
+                }
+                return list;
+            }
+            // 无季度值,根据当前日期获取当前季度
+            Calendar now = Calendar.getInstance();
+            int currentMonth = now.get(Calendar.MONTH) + 1; // 月份从0开始,所以加1
+            int currentQuarter = (currentMonth - 1) / 3 + 1; // 计算当前季度
+            for (int i = currentQuarter; i > 0; i--) {
+                dataTotal.setYear(year);
+                dataTotal.setSeason(String.valueOf(i));
+                currentDataTotal = service.selectEnterpriseBaseDataTotalList(dataTotal);
+                if (i==1){
+                    //第一季度特殊处理
+                    int _year = Integer.parseInt(year) - 1;
+                    dataTotal.setYear(String.valueOf(_year));
+                    dataTotal.setSeason("4");
+                }else {
+                    dataTotal.setSeason(String.valueOf(i - 1));
+                }
+                previousDataTotal = service.selectEnterpriseBaseDataTotalList(dataTotal);
+                //判断分析方式
+                if (businessMonitorAssess.getMode().equals("trendAnalysis")) {
+                    compareTrendAnalysis(currentDataTotal, previousDataTotal, list);
+                } else if (businessMonitorAssess.getMode().equals("avgAnalysis")) {
+                    compareAvgAnalysis(previousDataTotal, list, year, String.valueOf(i));
+                }
+            }
+            return list;
+        }
+        return list;
+    }
+
+
+    public static void setDataWithYearAndSeason(String year, String season, EnterpriseBaseDataTotal dataTotal){
+        dataTotal.setSeason(season);
+        dataTotal.setYear(year);
+    }
+    /**
+     * 计算某年某月的上一季度
+     * @param assess
+     * @param dataTotal
+     */
+    public static void getPreviousQuarter(BenefitMonitorAssess assess, EnterpriseBaseDataTotal dataTotal) {
+        int year = Integer.parseInt(assess.getYear());   // 将字符串转换为整数
+        int season = Integer.parseInt(assess.getSeason()); // 将字符串转换为整数
+        if (season == 1) {
+            dataTotal.setYear(String.valueOf(year - 1)); // 如果是第一季度,返回上一年第四季度
+        } else {
+            dataTotal.setSeason(String.valueOf(season - 1)); // 否则返回当前年份,季度减一
+        }
+    }
+
+    /**
+     * 对比数据--趋势分析
+     * @param currentQuarterList 当前季度数据
+     * @param previousQuarterList 上季度数据
+     */
+    public static void compareTrendAnalysis(List<EnterpriseBaseDataTotal> currentQuarterList, List<EnterpriseBaseDataTotal> previousQuarterList, List<BenefitMonitorAssess> list) {
+        // 使用 HashMap 缓存上个季度的数据,根据企业 ID 快速查找
+        Map<String, List<EnterpriseBaseDataTotal>> previousDataMap = new HashMap<>();
+
+        for (EnterpriseBaseDataTotal data : previousQuarterList) {
+            previousDataMap.computeIfAbsent(data.getEnterpriseName(), k -> new ArrayList<>()).add(data); // 按企业 ID 存储
+        }
+        //当前企业
+        String enterpriseName = "";
+        // 遍历当前季度数据,进行比较
+        for (EnterpriseBaseDataTotal currentData : currentQuarterList) {
+            //判断是否已经对比过该企业
+            if (enterpriseName.isEmpty() || !enterpriseName.equals(currentData.getEnterpriseName())) {
+                enterpriseName = currentData.getEnterpriseName();
+                List<EnterpriseBaseDataTotal> previousDataList = previousDataMap.get(enterpriseName); // 获取对应的上个季度数据
+                if (previousDataList != null) { // 检查上一季度是否存在数据
+                    //设置对比旗子
+                    //List<Boolean> taxChangeTrend = new ArrayList<>();
+                    List<Boolean> powerChangeTrend = new ArrayList<>();
+                    List<Boolean> outputChangeTrend = new ArrayList<>();
+                    //初始化第一个月数据
+                    EnterpriseBaseDataTotal previousFirstData = previousDataList.get(0);
+                    double previousTotalOutput = previousFirstData.getTotalIndustrialValue();
+                    double previousPower = previousFirstData.getPowerConsume();
+                    //long previousTax = previousDataList.get(0).getPaidTax();
+                    //初始化两个季度的实缴税金总额
+                    double currentQuarterTaxSum = 0L;
+                    double currentQuarterIncomeSum = 0L;
+                    double previousQuarterTaxSum = previousFirstData.getPaidTax();
+                    double previousQuarterIncomeSum = previousFirstData.getTaxableIncome();
+
+                    for (int i = 1; i < previousDataList.size(); i++) {
+                        double currentOutput = previousDataList.get(i).getTotalIndustrialValue();
+                        double currentPower = previousDataList.get(i).getPowerConsume();
+                        //累加上季度实缴税金
+                        double currentTax = previousDataList.get(i).getPaidTax();
+                        double currentIncome = previousDataList.get(i).getTaxableIncome();
+                        previousQuarterTaxSum += currentTax;
+                        previousQuarterIncomeSum += currentIncome;
+                        // 记录变化趋势
+                        //taxChangeTrend.add(currentTax > previousTax);
+                        powerChangeTrend.add(currentPower > previousPower);
+                        outputChangeTrend.add(currentOutput > previousTotalOutput);
+                        //更新为下个月数据
+                        previousTotalOutput = currentOutput;
+                        previousPower = currentPower;
+                        //previousTax = currentTax;
+                    }
+
+                    // 计算当前季度交税值总和
+                    for (EnterpriseBaseDataTotal current : currentQuarterList) {
+                        if (current.getEnterpriseName().equals(currentData.getEnterpriseName())) {
+                            currentQuarterTaxSum += current.getPaidTax(); // 累加交税值
+                            currentQuarterIncomeSum += current.getTaxableIncome(); //累加应付值
+                        }
+                    }
+                    //创建实体类
+                    BenefitMonitorAssess assess = new BenefitMonitorAssess();
+                    assess.setYear(currentData.getYear());
+                    assess.setSeason(currentData.getSeason());
+                    assess.setEnterpriseName(enterpriseName);
+                    assess.setCode(currentData.getCode());
+                    // 当前季度和上个季度交税值比较并填充返回的list(指标解耦)
+                    if (currentQuarterTaxSum > previousQuarterTaxSum) {
+                        //交税大于上季度
+                        if (determineTrend(outputChangeTrend).equals("0") && determineTrend(powerChangeTrend).equals("0")) {
+                            assess.setTrendAnalysis("连续近三个月,工业产值持续升高、电力消耗持续升高、本季度实缴税金相较上一季度升高");
+                            assess.setOperationalEvaluate("企业订单增加,市场份额提升,对地区经济发展的贡献度提高");
+                            list.add(assess);
+                        }else if (determineTrend(outputChangeTrend).equals("0") && determineTrend(powerChangeTrend).equals("1")) {
+                            assess.setTrendAnalysis("连续近三个月,工业产值持续升高、电力消耗持续下降、本季度实缴税金相较上一季度升高");
+                            assess.setOperationalEvaluate("企业订单增加,市场份额提升,对地区行业和经济发展的贡献度提高,可能存在技术或设备更新");
+                            list.add(assess);
+                        } else if (determineTrend(outputChangeTrend).equals("1") && determineTrend(powerChangeTrend).equals("0")) {
+                            assess.setTrendAnalysis("连续近三个月,工业产值持续下降、电力消耗持续升高、本季度实缴税金相较上一季度升高");
+                            assess.setOperationalEvaluate("企业上报数据可能存在错误,企业生产经营情况可能存在异常");
+                            list.add(assess);
+                        } else if (determineTrend(outputChangeTrend).equals("1") && determineTrend(powerChangeTrend).equals("1")) {
+                            assess.setTrendAnalysis("连续近三个月,工业产值持续下降、电力消耗持续下降、本季度实缴税金相较上一季度升高");
+                            assess.setOperationalEvaluate("企业上报数据可能存在错误,企业生产经营情况可能存在异常");
+                            list.add(assess);
+                        } else if (determineTrend(outputChangeTrend).equals("2") || determineTrend(powerChangeTrend).equals("2")) {
+                            //(月度数据波动情况下)
+                            if (currentQuarterIncomeSum > previousQuarterIncomeSum){
+                                //应付大于上季度
+                                assess.setTrendAnalysis("连续三个月,工业产值和电力消耗存在小幅波动、本季度应税收入和实缴税金相较上一季度均升高");
+                                assess.setOperationalEvaluate("企业生产经营情况良好");
+                                list.add(assess);
+                            }else {
+                                //应付小于上季度
+                                assess.setTrendAnalysis("连续三个月,工业产值和电力消耗存在小幅波动、本季度应税收入相较上一季度下降,实缴税金相较上一季度升高");
+                                assess.setOperationalEvaluate("企业生产经营情况可能存在异常");
+                                list.add(assess);
+                            }
+                        } else {
+                            LOGGER.log(Level.WARNING, "企业名称: {0} - 对比数据出错", currentData.getEnterpriseName());
+                        }
+                    } else {
+                        //交税小于上季度
+                        if (determineTrend(outputChangeTrend).equals("0") && determineTrend(powerChangeTrend).equals("0")) {
+                            assess.setTrendAnalysis("连续近三个月,工业产值持续升高、电力消耗持续升高、本季度实缴税金相较上一季度下降");
+                            assess.setOperationalEvaluate("企业订单增加,市场份额提升,可能存在退税、政策扶持或缴税异常");
+                            list.add(assess);
+                        }else if (determineTrend(outputChangeTrend).equals("0") && determineTrend(powerChangeTrend).equals("1")) {
+                            assess.setTrendAnalysis("连续近三个月,工业产值持续升高、电力消耗持续下降、本季度实缴税金相较上一季度下降");
+                            assess.setOperationalEvaluate("企业订单增加,市场份额提升,可能存在退税、政策扶持或缴税异常,可能存在技术或设备更新");
+                            list.add(assess);
+                        } else if (determineTrend(outputChangeTrend).equals("1") && determineTrend(powerChangeTrend).equals("0")) {
+                            assess.setTrendAnalysis("连续近三个月,工业产值持续下降、电力消耗持续升高、本季度实缴税金相较上一季度下降");
+                            assess.setOperationalEvaluate("企业生产经营情况可能存在异常");
+                            list.add(assess);
+                        } else if (determineTrend(outputChangeTrend).equals("1") && determineTrend(powerChangeTrend).equals("1")) {
+                            assess.setTrendAnalysis("连续近三个月,工业产值持续下降、电力消耗持续下降、本季度实缴税金相较上一季度下降");
+                            assess.setOperationalEvaluate("企业订单减少,市场份额萎缩,企业生产经营情况可能存在异常");
+                            list.add(assess);
+                        }else if (determineTrend(outputChangeTrend).equals("2") || determineTrend(powerChangeTrend).equals("2")) {
+                            //(月度数据波动情况下)
+                            if (currentQuarterIncomeSum > previousQuarterIncomeSum){
+                                //应付大于上季度
+                                assess.setTrendAnalysis("连续三个月,工业产值和电力消耗存在小幅波动、本季度应税收入相较上一季度升高,实缴税金相较上一季度下降");
+                                assess.setOperationalEvaluate("企业生产经营情况良好,可能存在退税、政策扶持或缴税异常");
+                                list.add(assess);
+                            }else {
+                                //应付小于上季度
+                                assess.setTrendAnalysis("连续三个月,工业产值和电力消耗存在小幅波动、本季度应税收入和实缴税金相较上一季度均下降");
+                                assess.setOperationalEvaluate("企业生产经营情况一般");
+                                list.add(assess);
+                            }
+                        } else {
+                            LOGGER.log(Level.WARNING, "企业名称: {0} - 对比数据出错", currentData.getEnterpriseName());
+                        }
+                    }
+
+                } else {
+                    LOGGER.log(Level.WARNING, "企业名称: {0} - 上个季度无数据", currentData.getEnterpriseName());
+                }
+            }
+        }
+    }
+
+    /**
+     * 季度对比
+     * @param trends
+     * @return
+     */
+    private static String determineTrend(List<Boolean> trends) {
+        boolean allIncreasing = true;
+        boolean allDecreasing = true;
+
+        for (Boolean trend : trends) {
+            if (!trend) {
+                allIncreasing = false;
+            }
+            if (trend) {
+                allDecreasing = false;
+            }
+        }
+
+        if (allIncreasing) {
+            //递增
+            return "0";
+        } else if (allDecreasing) {
+            //递减
+            return "1";
+        } else {
+            //波动
+            return "2"; // 有增有减
+        }
+    }
+
+    /**
+     * 平均水平对比
+     * @param previousQuarterList 上季度数据
+     * @param list 返回的结果list
+     */
+    public static void compareAvgAnalysis(List<EnterpriseBaseDataTotal> previousQuarterList, List<BenefitMonitorAssess> list, String year, String season){
+        String enterpriseName = "";
+        Double industrialValueSum = 0.0;
+        Double paidTaxSum = 0.0;
+        int i = 1;
+        List<AvgBenefit> benefits = new ArrayList<>();
+        //统计多个或一个企业的近三个月总产值和交税总值
+        for (EnterpriseBaseDataTotal item : previousQuarterList){
+            if (!enterpriseName.equals(item.getEnterpriseName())){
+                //当企业不相同或者第一次为空,初始化统计数
+                if (!enterpriseName.isEmpty()){
+                    //非空即已统计完毕一个企业
+                    AvgBenefit benefit = new AvgBenefit();
+                    benefit.setEnterpriseName(enterpriseName);
+                    benefit.setCode(item.getCode());
+                    benefit.setIndustrialValueAvg(industrialValueSum / i);
+                    benefit.setPaidTaxAvg(paidTaxSum / i);
+                    benefits.add(benefit);
+                }
+                enterpriseName = item.getEnterpriseName();
+                industrialValueSum = item.getTotalIndustrialValue();
+                paidTaxSum = item.getPaidTax();
+                i = 1;
+            }else {
+                //企业相同直接相加
+                industrialValueSum += item.getTotalIndustrialValue();
+                paidTaxSum += item.getPaidTax();
+                i += 1;
+                if (i == previousQuarterList.size() ){
+                    //单企业统计到尽头,即已统计完毕一个企业
+                    AvgBenefit benefit = new AvgBenefit();
+                    benefit.setEnterpriseName(enterpriseName);
+                    benefit.setCode(item.getCode());
+                    benefit.setIndustrialValueAvg(industrialValueSum / i);
+                    benefit.setPaidTaxAvg(paidTaxSum / i);
+                    benefits.add(benefit);
+                }
+            }
+        }
+        Map<String, IndustrySummary> industrySummaryMap = previousQuarterList.stream()
+                .collect(Collectors.groupingBy(
+                        EnterpriseBaseDataTotal::getCode,
+                        Collectors.collectingAndThen(
+                                Collectors.toList(),
+                                enterpriseBaseData -> {
+                                    double totalIndustrialValue = enterpriseBaseData.stream()
+                                            .mapToDouble(EnterpriseBaseDataTotal::getTotalIndustrialValue)
+                                            .sum();
+                                    double totalPaidTax = enterpriseBaseData.stream()
+                                            .mapToDouble(EnterpriseBaseDataTotal::getPaidTax)
+                                            .sum();
+                                    int uniqueEnterpriseCount = (int) enterpriseBaseData.stream()
+                                            .map(EnterpriseBaseDataTotal::getEnterpriseName)
+                                            .distinct()
+                                            .count();
+
+                                    return new IndustrySummary(totalIndustrialValue, totalPaidTax, uniqueEnterpriseCount);
+                                }
+                        )
+                ));
+        for (AvgBenefit item : benefits){
+            BenefitMonitorAssess assess = new BenefitMonitorAssess();
+            assess.setEnterpriseName(item.getEnterpriseName());
+            assess.setCode(item.getCode());
+            assess.setYear(year);
+            assess.setSeason(season);
+            //开始平均水平分析
+            IndustrySummary industrySummary = industrySummaryMap.get(item.getCode());
+            if (item.getIndustrialValueAvg() < industrySummary.getIndustrialValueSum() / industrySummary.getEnterpriseNumber() && item.getPaidTaxAvg() < industrySummary.getPaidTaxSum() / industrySummary.getEnterpriseNumber()){
+                assess.setAvgAnalysis("近三个月工业总产值低于行业平均水平,且本季度实缴税金低于行业平均水平");
+                assess.setOperationalEvaluate("企业生产经营状况一般,行业竞争力较弱");
+            }else if (item.getIndustrialValueAvg() > industrySummary.getIndustrialValueSum() / industrySummary.getEnterpriseNumber() && item.getPaidTaxAvg() > industrySummary.getPaidTaxSum() / industrySummary.getEnterpriseNumber()){
+                assess.setAvgAnalysis("近三个月工业总产值高于行业平均水平,且本季度实缴税金高于行业平均水平");
+                assess.setOperationalEvaluate("企业生产经营状况良好,具备行业竞争力");
+            }else if (item.getIndustrialValueAvg() < industrySummary.getIndustrialValueSum() / industrySummary.getEnterpriseNumber() && item.getPaidTaxAvg() > industrySummary.getPaidTaxSum() / industrySummary.getEnterpriseNumber()){
+                assess.setAvgAnalysis("近三个月工业总产值低于行业平均水平,且本季度实缴税金高于行业平均水平");
+                assess.setOperationalEvaluate("企业上报数据可能存在错误,企业生产经营情况可能存在异常");
+            }else if (item.getIndustrialValueAvg() > industrySummary.getIndustrialValueSum() / industrySummary.getEnterpriseNumber() && item.getPaidTaxAvg() < industrySummary.getPaidTaxSum() / industrySummary.getEnterpriseNumber()){
+                assess.setAvgAnalysis("近三个月工业总产值高于行业平均水平,且本季度实缴税金低于行业平均水平");
+                assess.setOperationalEvaluate("企业生产经营状况一般,行业竞争力良好,可能存在退税、政策扶持或缴税异常等情况");
+            }else {
+                LOGGER.log(Level.WARNING, "企业名称: {0} - 上个季度无数据或任一数据没有变化", item.getEnterpriseName());
+            }
+            list.add(assess);
+        }
+    }
+}

+ 0 - 5
enteprise-admin/src/main/java/com/enteprise/business_monitor_assess/mapper/BusinessMonitorAssessMapper.java

@@ -1,5 +0,0 @@
-package com.enteprise.business_monitor_assess.mapper;
-
-public interface BusinessMonitorAssessMapper {
-
-}

+ 0 - 10
enteprise-admin/src/main/java/com/enteprise/business_monitor_assess/service/IBusinessMonitorAssessService.java

@@ -1,10 +0,0 @@
-package com.enteprise.business_monitor_assess.service;
-
-import com.enteprise.business_monitor_assess.domain.BusinessMonitorAssess;
-
-import java.util.List;
-
-public interface IBusinessMonitorAssessService {
-
-    public List<BusinessMonitorAssess> getListByBusinessMonitorAssess(BusinessMonitorAssess businessMonitorAssess);
-}

+ 0 - 30
enteprise-admin/src/main/java/com/enteprise/business_monitor_assess/service/impl/BusinessMonitorAssessService.java

@@ -1,30 +0,0 @@
-package com.enteprise.business_monitor_assess.service.impl;
-
-import com.enteprise.business_monitor_assess.domain.BusinessMonitorAssess;
-import com.enteprise.business_monitor_assess.service.IBusinessMonitorAssessService;
-
-import java.util.List;
-
-public class BusinessMonitorAssessService implements IBusinessMonitorAssessService {
-    @Override
-    public List<BusinessMonitorAssess> getListByBusinessMonitorAssess(BusinessMonitorAssess businessMonitorAssess) {
-        //判断分析方式
-
-        //if趋势分析
-        //获取上一个季度的工业产值、电力消耗、实缴税金、本季度实缴税金
-
-        //if-elseif进行各种数据对比后输出一个case
-
-        //根据输出case选择对应的输出内容和补充businessMonitorAssess进行返回
-
-
-        //if平均水平分析
-        //获取上一个季度的总产值、行业平均水平、本季度实缴税金
-
-        //if-elseif进行各种数据对比后输出一个case
-
-        //根据输出case选择对应的输出内容和补充businessMonitorAssess进行返回
-
-        return null;
-    }
-}

+ 39 - 39
enteprise-admin/src/main/java/com/enteprise/industry_run/domain/EnterpriseBaseDataTotal.java

@@ -16,7 +16,7 @@ public class EnterpriseBaseDataTotal extends BaseEntity
     private static final long serialVersionUID = 1L;
 
     /** 主键 */
-    private Long id;
+    private Double id;
 
     /** 企业名称 */
     @Excel(name = "企业名称")
@@ -37,46 +37,46 @@ public class EnterpriseBaseDataTotal extends BaseEntity
     private String mainBusiness;
 
     /** 用地面积 */
-    private Long landArea;
+    private Double landArea;
 
     /** 工业总产值 */
     @Excel(name = "工业总产值")
-    private Long totalIndustrialValue;
+    private Double totalIndustrialValue;
 
     /** 工业增加值 */
-    private Long gdp;
+    private Double gdp;
 
     /** 应税收入 */
     @Excel(name = "应税收入")
-    private Long taxableIncome;
+    private Double taxableIncome;
 
     /** 实缴税金 */
     @Excel(name = "实缴税金")
-    private Long paidTax;
+    private Double paidTax;
 
     /** 主营业务收入 */
-    private Long mainBusinessIncome;
+    private Double mainBusinessIncome;
 
     /** 从业人员数 */
-    private Long employeeNumber;
+    private Double employeeNumber;
 
     /** 利润总额 */
-    private Long profit;
+    private Double profit;
 
     /** 所有者权益 */
-    private Long ownerEquity;
+    private Double ownerEquity;
 
     /** 研发经费 */
     @Excel(name = "研发经费")
-    private Long funding;
+    private Double funding;
 
     /** 能源消费量 */
     @Excel(name = "能源消费量")
-    private Long energyConsume;
+    private Double energyConsume;
 
     /** 用电量 */
     @Excel(name = "用电量")
-    private Long powerConsume;
+    private Double powerConsume;
 
     /** 年份 */
     @Excel(name = "年份")
@@ -90,12 +90,12 @@ public class EnterpriseBaseDataTotal extends BaseEntity
     @Excel(name = "月份")
     private String month;
 
-    public void setId(Long id) 
+    public void setId(Double id) 
     {
         this.id = id;
     }
 
-    public Long getId() 
+    public Double getId() 
     {
         return id;
     }
@@ -144,111 +144,111 @@ public class EnterpriseBaseDataTotal extends BaseEntity
     {
         return mainBusiness;
     }
-    public void setLandArea(Long landArea) 
+    public void setLandArea(Double landArea) 
     {
         this.landArea = landArea;
     }
 
-    public Long getLandArea() 
+    public Double getLandArea() 
     {
         return landArea;
     }
-    public void setTotalIndustrialValue(Long totalIndustrialValue) 
+    public void setTotalIndustrialValue(Double totalIndustrialValue) 
     {
         this.totalIndustrialValue = totalIndustrialValue;
     }
 
-    public Long getTotalIndustrialValue() 
+    public Double getTotalIndustrialValue() 
     {
         return totalIndustrialValue;
     }
-    public void setGdp(Long gdp) 
+    public void setGdp(Double gdp) 
     {
         this.gdp = gdp;
     }
 
-    public Long getGdp() 
+    public Double getGdp() 
     {
         return gdp;
     }
-    public void setTaxableIncome(Long taxableIncome) 
+    public void setTaxableIncome(Double taxableIncome) 
     {
         this.taxableIncome = taxableIncome;
     }
 
-    public Long getTaxableIncome() 
+    public Double getTaxableIncome()
     {
         return taxableIncome;
     }
-    public void setPaidTax(Long paidTax) 
+    public void setPaidTax(Double paidTax) 
     {
         this.paidTax = paidTax;
     }
 
-    public Long getPaidTax() 
+    public Double getPaidTax() 
     {
         return paidTax;
     }
-    public void setMainBusinessIncome(Long mainBusinessIncome) 
+    public void setMainBusinessIncome(Double mainBusinessIncome) 
     {
         this.mainBusinessIncome = mainBusinessIncome;
     }
 
-    public Long getMainBusinessIncome() 
+    public Double getMainBusinessIncome() 
     {
         return mainBusinessIncome;
     }
-    public void setEmployeeNumber(Long employeeNumber) 
+    public void setEmployeeNumber(Double employeeNumber) 
     {
         this.employeeNumber = employeeNumber;
     }
 
-    public Long getEmployeeNumber() 
+    public Double getEmployeeNumber() 
     {
         return employeeNumber;
     }
-    public void setProfit(Long profit) 
+    public void setProfit(Double profit) 
     {
         this.profit = profit;
     }
 
-    public Long getProfit() 
+    public Double getProfit() 
     {
         return profit;
     }
-    public void setOwnerEquity(Long ownerEquity) 
+    public void setOwnerEquity(Double ownerEquity) 
     {
         this.ownerEquity = ownerEquity;
     }
 
-    public Long getOwnerEquity() 
+    public Double getOwnerEquity() 
     {
         return ownerEquity;
     }
-    public void setFunding(Long funding) 
+    public void setFunding(Double funding) 
     {
         this.funding = funding;
     }
 
-    public Long getFunding() 
+    public Double getFunding() 
     {
         return funding;
     }
-    public void setEnergyConsume(Long energyConsume) 
+    public void setEnergyConsume(Double energyConsume) 
     {
         this.energyConsume = energyConsume;
     }
 
-    public Long getEnergyConsume() 
+    public Double getEnergyConsume() 
     {
         return energyConsume;
     }
-    public void setPowerConsume(Long powerConsume) 
+    public void setPowerConsume(Double powerConsume) 
     {
         this.powerConsume = powerConsume;
     }
 
-    public Long getPowerConsume() 
+    public Double getPowerConsume() 
     {
         return powerConsume;
     }

+ 2 - 1
enteprise-admin/src/main/resources/mapper/industry_run/EnterpriseBaseDataTotalMapper.xml

@@ -35,7 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectEnterpriseBaseDataTotalList" parameterType="EnterpriseBaseDataTotal" resultMap="EnterpriseBaseDataTotalResult">
         <include refid="selectEnterpriseBaseDataTotalVo"/>
         <where>  
-            <if test="enterpriseName != null  and enterpriseName != ''"> and enterprise_name like concat('%', #{enterpriseName}, '%')</if>
+            <if test="enterpriseName != null  and enterpriseName != ''"> and enterprise_name = #{enterpriseName}</if>
             <if test="location != null  and location != ''"> and location = #{location}</if>
             <if test="code != null  and code != ''"> and code = #{code}</if>
             <if test="totalIndustrialValue != null "> and total_industrial_value = #{totalIndustrialValue}</if>
@@ -48,6 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="season != null  and season != ''"> and season = #{season}</if>
             <if test="month != null  and month != ''"> and month = #{month}</if>
         </where>
+        order by enterprise_name,year,season,month
     </select>
     
     <select id="selectEnterpriseBaseDataTotalByEnterpriseName" parameterType="String" resultMap="EnterpriseBaseDataTotalResult">