|
@@ -7,16 +7,28 @@ import com.itextpdf.text.PageSize;
|
|
|
import com.itextpdf.text.Paragraph;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
|
|
+import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.PDFUtil;
|
|
|
+import com.ruoyi.system.domain.ProposalInfo;
|
|
|
import com.ruoyi.system.domain.member.MemberInfo;
|
|
|
+import com.ruoyi.system.domain.sqmy.SqmyInfo;
|
|
|
import com.ruoyi.system.domain.vo.MemberInfoVoTwo;
|
|
|
import com.ruoyi.system.mapper.MemberInfoMapper;
|
|
|
+import com.ruoyi.system.mapper.ProposalInfoMapper;
|
|
|
+import com.ruoyi.system.mapper.SqmyInfoMapper;
|
|
|
import com.ruoyi.system.mapper.SysDictDataMapper;
|
|
|
import com.ruoyi.system.service.IStatisticsService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -34,6 +46,12 @@ public class StatisticsServiceImpl implements IStatisticsService {
|
|
|
@Autowired
|
|
|
private SysDictDataMapper dictDataMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ProposalInfoMapper proposalInfoMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SqmyInfoMapper sqmyInfoMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 统计查询委员图形分析 界别
|
|
|
*/
|
|
@@ -57,28 +75,28 @@ public class StatisticsServiceImpl implements IStatisticsService {
|
|
|
memberInfoVoTwo.setSort(sysDictData.getDictSort());
|
|
|
String dictLabel = sysDictData.getDictLabel();
|
|
|
String dictValue = sysDictData.getDictValue();
|
|
|
- jsonObj.put("name",dictLabel);
|
|
|
+ jsonObj.put("name", dictLabel);
|
|
|
memberInfoVoTwo.setBoundary(dictLabel);
|
|
|
//柱状图
|
|
|
dictLabelList.add(dictLabel);
|
|
|
List<MemberInfo> memberInfoListV = memberInfoCollect.get(dictValue);
|
|
|
//如果没这个界别就输入0
|
|
|
- if (memberInfoListV != null && memberInfoListV.size() > 0){
|
|
|
+ if (memberInfoListV != null && memberInfoListV.size() > 0) {
|
|
|
dictValueList.add(memberInfoListV.size());
|
|
|
memberInfoVoTwo.setNum(memberInfoListV.size());
|
|
|
- jsonObj.put("value",memberInfoListV.size());
|
|
|
+ jsonObj.put("value", memberInfoListV.size());
|
|
|
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
dictValueList.add(0);
|
|
|
memberInfoVoTwo.setNum(0);
|
|
|
- jsonObj.put("value",0);
|
|
|
+ jsonObj.put("value", 0);
|
|
|
}
|
|
|
memberInfoVoTwoList.add(memberInfoVoTwo);
|
|
|
jsonObjsList.add(jsonObj);
|
|
|
}
|
|
|
- mapZ.put("x",dictLabelList );
|
|
|
- mapZ.put("y",dictValueList );
|
|
|
- mapZ.put("pieData",jsonObjsList );
|
|
|
+ mapZ.put("x", dictLabelList);
|
|
|
+ mapZ.put("y", dictValueList);
|
|
|
+ mapZ.put("pieData", jsonObjsList);
|
|
|
mapZ.put("total", memberInfoList.size());
|
|
|
mapZ.put("list", memberInfoVoTwoList);
|
|
|
}
|
|
@@ -88,6 +106,7 @@ public class StatisticsServiceImpl implements IStatisticsService {
|
|
|
|
|
|
/**
|
|
|
* 导出pdf
|
|
|
+ *
|
|
|
* @param response
|
|
|
*/
|
|
|
@Override
|
|
@@ -117,9 +136,9 @@ public class StatisticsServiceImpl implements IStatisticsService {
|
|
|
memberInfoVoTwo.setBoundary(dictLabel);
|
|
|
List<MemberInfo> memberInfoListV = memberInfoCollect.get(dictValue);
|
|
|
//如果没这个界别就输入0
|
|
|
- if (memberInfoListV != null && memberInfoListV.size() > 0){
|
|
|
+ if (memberInfoListV != null && memberInfoListV.size() > 0) {
|
|
|
memberInfoVoTwo.setNum(memberInfoListV.size());
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
memberInfoVoTwo.setNum(0);
|
|
|
}
|
|
|
memberInfoVoTwoList.add(memberInfoVoTwo);
|
|
@@ -131,7 +150,7 @@ public class StatisticsServiceImpl implements IStatisticsService {
|
|
|
methodNames.add("getBoundary");
|
|
|
methodNames.add("getNum");
|
|
|
// 生成table表格段落
|
|
|
- Paragraph table = PDFUtil.createTable(memberInfoVoTwoList, "界别统计表", new String[]{"序号","界别","人数"},methodNames );
|
|
|
+ Paragraph table = PDFUtil.createTable(memberInfoVoTwoList, "界别统计表", new String[]{"序号", "界别", "人数"}, methodNames);
|
|
|
|
|
|
// 将所有需要放到文档里的元素,汇总
|
|
|
List<Paragraph> paragraphs = new ArrayList<Paragraph>();
|
|
@@ -141,4 +160,272 @@ public class StatisticsServiceImpl implements IStatisticsService {
|
|
|
// 导出pdf文档:将paragraphs塞到document中,并下载document
|
|
|
PDFUtil.exportDocument(document, null, paragraphs, response, "报表");
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult threeData() throws ParseException {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ //获取当前时间
|
|
|
+ String endTime = DateUtils.getTime();
|
|
|
+ //获取三个月前的时间
|
|
|
+ String strTime = DateUtils.lastMouth(DateUtils.getMonth(), -2) + "-01" + " 00:00:00";
|
|
|
+ //查询近三月提案数
|
|
|
+ ProposalInfo proposalInfo = new ProposalInfo();
|
|
|
+ proposalInfo.setStartTime(strTime);
|
|
|
+ proposalInfo.setEndTime(endTime);
|
|
|
+ List<ProposalInfo> proposalInfos = proposalInfoMapper.selectProposalInfoList(proposalInfo);
|
|
|
+ Map<String, Object> threeTaMap = new HashMap<>();
|
|
|
+ threeTaMap.put("time", strTime.split(" ")[0] + "-" + endTime.split(" ")[0]);
|
|
|
+ threeTaMap.put("threeTa", 0);
|
|
|
+ if (proposalInfos != null) {
|
|
|
+ threeTaMap.put("threeTa", proposalInfos.size());
|
|
|
+ }
|
|
|
+ map.put("threeTaMap", threeTaMap);
|
|
|
+
|
|
|
+
|
|
|
+ //查询近三月社情民意数
|
|
|
+ SqmyInfo sqmyInfo = new SqmyInfo();
|
|
|
+ sqmyInfo.setStartTime(strTime);
|
|
|
+ sqmyInfo.setEndTime(endTime);
|
|
|
+ List<SqmyInfo> sqmyInfos = sqmyInfoMapper.selectSqmyInfoList(sqmyInfo);
|
|
|
+ Map<String, Object> threeSqmyMap = new HashMap<>();
|
|
|
+ threeSqmyMap.put("time", strTime.split(" ")[0] + "-" + endTime.split(" ")[0]);
|
|
|
+ threeSqmyMap.put("threesqmy", 0);
|
|
|
+ if (sqmyInfos != null) {
|
|
|
+ threeSqmyMap.put("threesqmy", sqmyInfos.size());
|
|
|
+ }
|
|
|
+ map.put("threeSqmyMap", threeSqmyMap);
|
|
|
+
|
|
|
+
|
|
|
+ //较上周委员提案
|
|
|
+ //获取上周第一天
|
|
|
+ String previousWeekMonday = DateUtils.getPreviousWeekMonday();
|
|
|
+ //获取上周最一天
|
|
|
+ String previousWeekSunday = DateUtils.getPreviousWeekSunday();
|
|
|
+ //上周数量
|
|
|
+ int lastWeek = 0;
|
|
|
+ //本周第一天
|
|
|
+ String thisWeekMonday = DateUtils.getThisWeekMonday();
|
|
|
+ //本周数量
|
|
|
+ int week = 0;
|
|
|
+ Map<String, Object> taMap = new HashMap<>();
|
|
|
+ //0:正,1:负
|
|
|
+ taMap.put("symbol", 0);
|
|
|
+ taMap.put("percent", "0%");
|
|
|
+ if (proposalInfos != null && proposalInfos.size() > 0) {
|
|
|
+ for (ProposalInfo info : proposalInfos) {
|
|
|
+ if (DateUtils.isEffectiveDate(String.valueOf(info.getCreateTime()), previousWeekMonday, previousWeekSunday)) {
|
|
|
+ lastWeek++;
|
|
|
+ } else if (DateUtils.isEffectiveDate(String.valueOf(info.getCreateTime()), thisWeekMonday, endTime)) {
|
|
|
+ week++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (lastWeek > week) {
|
|
|
+ taMap.put("symbol", 1);
|
|
|
+ }
|
|
|
+ BigDecimal num1 = new BigDecimal(lastWeek);
|
|
|
+ BigDecimal num2 = new BigDecimal(week);
|
|
|
+ BigDecimal subNum1 = num2.subtract(num1);
|
|
|
+ //subNum1/num1
|
|
|
+ double result = Double.parseDouble(((subNum1.divide(num1, 2, BigDecimal.ROUND_HALF_UP))).toString());
|
|
|
+ if (result < 0) {
|
|
|
+ result = result * -1;
|
|
|
+ }
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("0%"); // 创建DecimalFormat对象并设置格式化模式为"0%"
|
|
|
+ String percentage = decimalFormat.format((result)); // 使用DecimalFormat对象进行格式化操作
|
|
|
+ taMap.put("percent", percentage);
|
|
|
+ map.put("taMap", taMap);
|
|
|
+
|
|
|
+ //较上月上报社情民意
|
|
|
+ //上一个月开始时间
|
|
|
+ String lastStartMonth = DateUtils.lastMouth(DateUtils.getMonth(), -1) + "-01" + " 00:00:00";
|
|
|
+ //上一个月结束时间
|
|
|
+ String lastEndtMonth = DateUtils.lastMouth(DateUtils.getMonth(), -1) + "-31" + " 23:59:59";
|
|
|
+ //上月数量
|
|
|
+ int lastMonth = 0;
|
|
|
+ //本月开始时间
|
|
|
+ String startMonth = DateUtils.lastMouth(DateUtils.getMonth(), 0) + "-01" + " 00:00:00";
|
|
|
+ //本月数量
|
|
|
+ int month = 0;
|
|
|
+ Map<String, Object> sqmyMap = new HashMap<>();
|
|
|
+ //0:正,1:负
|
|
|
+ sqmyMap.put("symbol", 0);
|
|
|
+ sqmyMap.put("percent", "0%");
|
|
|
+ if (sqmyInfos != null && sqmyInfos.size() > 0) {
|
|
|
+ for (SqmyInfo info : sqmyInfos) {
|
|
|
+ if (DateUtils.isEffectiveDate(String.valueOf(info.getCreateTime()), lastStartMonth, lastEndtMonth)) {
|
|
|
+ lastMonth++;
|
|
|
+ } else if (DateUtils.isEffectiveDate(String.valueOf(info.getCreateTime()), startMonth, endTime)) {
|
|
|
+ month++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BigDecimal monthNum1 = new BigDecimal(lastMonth);
|
|
|
+ BigDecimal monthNum2 = new BigDecimal(month);
|
|
|
+ BigDecimal monthsubNum1 = monthNum2.subtract(monthNum1);
|
|
|
+ //subNum1/num1
|
|
|
+ double resultMonth = Double.parseDouble(((monthsubNum1.divide(monthNum1, 2, BigDecimal.ROUND_HALF_UP))).toString());
|
|
|
+ if (resultMonth < 0) {
|
|
|
+ resultMonth = resultMonth * -1;
|
|
|
+ }
|
|
|
+ taMap.put("percent", decimalFormat.format((resultMonth)));
|
|
|
+ map.put("sqmyMap", sqmyMap);
|
|
|
+ return AjaxResult.success(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult weekData() throws ParseException {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ //获取当前时间
|
|
|
+ String endTime = DateUtils.getTime();
|
|
|
+ //本周第一天
|
|
|
+ String strTime = DateUtils.getThisWeekMonday();
|
|
|
+ //获取本周的所有日期
|
|
|
+ List<String> weekList = DateUtils.getWeekData(DateUtils.getDate());
|
|
|
+ map.put("week", weekList);
|
|
|
+ //查询本周提案数
|
|
|
+ ProposalInfo proposalInfo = new ProposalInfo();
|
|
|
+ proposalInfo.setStartTime(strTime);
|
|
|
+ proposalInfo.setEndTime(endTime);
|
|
|
+ List<ProposalInfo> proposalInfos = proposalInfoMapper.selectProposalInfoList(proposalInfo);
|
|
|
+ List<Integer> taInt = new ArrayList<>();
|
|
|
+ Boolean tbl = proposalInfos != null && proposalInfos.size() > 0;
|
|
|
+ for (int i = 0; i < weekList.size(); i++) {
|
|
|
+ int num = 0;
|
|
|
+ if (tbl) {
|
|
|
+ for (ProposalInfo info : proposalInfos) {
|
|
|
+ if (String.valueOf(info.getCreateTime()).contains(weekList.get(i))) {
|
|
|
+ num++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ taInt.add(num);
|
|
|
+ }
|
|
|
+ map.put("taInt", taInt);
|
|
|
+ //查询本周社情民意数
|
|
|
+ SqmyInfo sqmyInfo = new SqmyInfo();
|
|
|
+ sqmyInfo.setStartTime(strTime);
|
|
|
+ sqmyInfo.setEndTime(endTime);
|
|
|
+ List<SqmyInfo> sqmyInfos = sqmyInfoMapper.selectSqmyInfoList(sqmyInfo);
|
|
|
+ List<Integer> sqmyInt = new ArrayList<>();
|
|
|
+ Boolean sbl = sqmyInfos != null && sqmyInfos.size() > 0;
|
|
|
+ for (int i = 0; i < weekList.size(); i++) {
|
|
|
+ int num = 0;
|
|
|
+ if (sbl) {
|
|
|
+ for (SqmyInfo info : sqmyInfos) {
|
|
|
+ if (String.valueOf(info.getCreateTime()).contains(weekList.get(i))) {
|
|
|
+ num++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sqmyInt.add(num);
|
|
|
+ }
|
|
|
+ map.put("sqmyInt", sqmyInt);
|
|
|
+ return AjaxResult.success(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult quarterData() {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ //获取当前时间
|
|
|
+ String endTime = DateUtils.getTime();
|
|
|
+ //本季度第一天
|
|
|
+ String strTime = DateUtils.getQuarterFirst() + " 00:00:00";
|
|
|
+ //查询本周提案数
|
|
|
+ ProposalInfo proposalInfo = new ProposalInfo();
|
|
|
+ proposalInfo.setStartTime(strTime);
|
|
|
+ proposalInfo.setEndTime(endTime);
|
|
|
+ List<ProposalInfo> proposalInfos = proposalInfoMapper.selectProposalInfoList(proposalInfo);
|
|
|
+ //已立案
|
|
|
+ int yla = 0;
|
|
|
+ Map<String, Object> ylaMap = new HashMap<>();
|
|
|
+ ylaMap.put("percent", "0%");
|
|
|
+ ylaMap.put("name", "已立案");
|
|
|
+ ylaMap.put("num", yla);
|
|
|
+
|
|
|
+ //未立案
|
|
|
+ int wla = 0;
|
|
|
+ Map<String, Object> wlaMap = new HashMap<>();
|
|
|
+ wlaMap.put("percent", "0%");
|
|
|
+ wlaMap.put("name", "已立案");
|
|
|
+ wlaMap.put("num", wla);
|
|
|
+
|
|
|
+ //已办结
|
|
|
+ int ybj = 0;
|
|
|
+ Map<String, Object> ybjMap = new HashMap<>();
|
|
|
+ ybjMap.put("percent", "0%");
|
|
|
+ ybjMap.put("name", "已立案");
|
|
|
+ ybjMap.put("num", ybj);
|
|
|
+
|
|
|
+ //未办结
|
|
|
+ int wbj = 0;
|
|
|
+ Map<String, Object> wbjMap = new HashMap<>();
|
|
|
+ wbjMap.put("percent", "0%");
|
|
|
+ wbjMap.put("name", "已立案");
|
|
|
+ wbjMap.put("num", wbj);
|
|
|
+
|
|
|
+ //待办理
|
|
|
+ int dbl = 0;
|
|
|
+ Map<String, Object> dblMap = new HashMap<>();
|
|
|
+ dblMap.put("percent", "0%");
|
|
|
+ dblMap.put("name", "已立案");
|
|
|
+ dblMap.put("num", dbl);
|
|
|
+ if (proposalInfos!=null && proposalInfos.size()>0) {
|
|
|
+ for (ProposalInfo info : proposalInfos) {
|
|
|
+ if (Integer.parseInt(info.getProposalProgress()) >= 2 && !"3".equals(info.getProposalProgress())) {
|
|
|
+ yla++;
|
|
|
+ if ("8".equals(info.getProposalProgress())) {
|
|
|
+ ybj++;
|
|
|
+ } else {
|
|
|
+ wbj++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("3".equals(info.getProposalProgress())) {
|
|
|
+ wla++;
|
|
|
+ }
|
|
|
+ if ("0".equals(info.getProposalProgress()) || "1".equals(info.getProposalProgress())) {
|
|
|
+ dbl++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal num1 = new BigDecimal(proposalInfos.size());
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("0%"); // 创建DecimalFormat对象并设置格式化模式为"0%"
|
|
|
+
|
|
|
+ //已立案
|
|
|
+ BigDecimal num2 = new BigDecimal(yla);
|
|
|
+ //num2/num1
|
|
|
+ double ylaResult = Double.parseDouble(((num2.divide(num1, 2, BigDecimal.ROUND_HALF_UP))).toString());
|
|
|
+ ylaMap.put("percent", decimalFormat.format((ylaResult)));
|
|
|
+
|
|
|
+ //未立案
|
|
|
+ BigDecimal num3 = new BigDecimal(wla);
|
|
|
+ //num2/num1
|
|
|
+ double wlaResult = Double.parseDouble(((num3.divide(num1, 2, BigDecimal.ROUND_HALF_UP))).toString());
|
|
|
+ wlaMap.put("percent", decimalFormat.format((wlaResult)));
|
|
|
+
|
|
|
+ //已办结
|
|
|
+ BigDecimal num4 = new BigDecimal(ybj);
|
|
|
+ //num2/num1
|
|
|
+ double ybjResult = Double.parseDouble(((num3.divide(num4, 2, BigDecimal.ROUND_HALF_UP))).toString());
|
|
|
+ ybjMap.put("percent", decimalFormat.format((ybjResult)));
|
|
|
+
|
|
|
+ //未办结
|
|
|
+ BigDecimal num5 = new BigDecimal(wbj);
|
|
|
+ //num2/num1
|
|
|
+ double wbjResult = Double.parseDouble(((num3.divide(num5, 2, BigDecimal.ROUND_HALF_UP))).toString());
|
|
|
+ wbjMap.put("percent", decimalFormat.format((wbjResult)));
|
|
|
+
|
|
|
+ //待办理
|
|
|
+ BigDecimal num6 = new BigDecimal(dbl);
|
|
|
+ //num2/num1
|
|
|
+ double dblResult = Double.parseDouble(((num3.divide(num6, 2, BigDecimal.ROUND_HALF_UP))).toString());
|
|
|
+ dblMap.put("percent", decimalFormat.format((dblResult)));
|
|
|
+ }
|
|
|
+ map.put("ylaMap",ylaMap);
|
|
|
+ map.put("wlaMap",wlaMap);
|
|
|
+ map.put("ybjMap",ybjMap);
|
|
|
+ map.put("wbjMap",wbjMap);
|
|
|
+ map.put("dblMap",dblMap);
|
|
|
+ return AjaxResult.success(map);
|
|
|
+ }
|
|
|
}
|