Commit 424dfb0e authored by zhangjianqian's avatar zhangjianqian

Merge remote-tracking branch 'origin/master'

parents 3d5214d2 c2683a32
......@@ -5,7 +5,7 @@ public class HiddenStatVO {
/**
* 隐患发现月份
*/
private int month;
private String month;
/**
* 发现隐患数量
......@@ -17,11 +17,11 @@ public class HiddenStatVO {
*/
private int rectifiedCount;
public int getMonth() {
public String getMonth() {
return month;
}
public void setMonth(int month) {
public void setMonth(String month) {
this.month = month;
}
......
package com.zehong.system.service.impl;
import java.math.BigDecimal;
import java.util.*;
import com.zehong.common.core.domain.entity.SysDept;
import com.zehong.common.utils.DateUtils;
import com.zehong.system.domain.THiddenTroubleWork;
import com.zehong.system.domain.TStaningBook;
import com.zehong.system.domain.vo.HiddenStatVO;
import com.zehong.system.mapper.SysDeptMapper;
import com.zehong.system.mapper.THiddenTroubleWorkMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TStaningBookMapper;
import com.zehong.system.domain.TStaningBook;
import com.zehong.system.service.ITStaningBookService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 隐患台账Service业务层处理
......@@ -24,6 +24,7 @@ import com.zehong.system.service.ITStaningBookService;
@Service
public class TStaningBookServiceImpl implements ITStaningBookService
{
private static final Logger logger = LoggerFactory.getLogger(TStaningBookServiceImpl.class);
@Autowired
private TStaningBookMapper tStaningBookMapper;
@Autowired
......@@ -125,62 +126,76 @@ public class TStaningBookServiceImpl implements ITStaningBookService
@Override
public Map<String,List> hiddenStat(Integer troubleLevel, Date beginTime, Date endTime){
Map<String,List> result = new HashMap<>(16);
List<HiddenStatVO> barData = tStaningBookMapper.hiddenBarStat(troubleLevel,beginTime,endTime);
//柱状图月份数据
List<String> months = new ArrayList<>();
//柱状图隐患数量
List<Integer> hiddens = new ArrayList<>();
//柱状图整改数量
List<Integer> rectifieds = new ArrayList<>();
for(HiddenStatVO hidden : barData){
months.add(changeMonth(hidden.getMonth()));
hiddens.add(hidden.getHiddenCount());
rectifieds.add(hidden.getRectifiedCount());
try {
List<HiddenStatVO> barData = tStaningBookMapper.hiddenBarStat(troubleLevel,beginTime,endTime);
//柱状图月份数据
List<String> months = getMonthBetweenDate(beginTime,endTime);
//柱状图隐患数量
List<Integer> hiddens = new ArrayList<>();
//柱状图整改数量
List<Integer> rectifieds = new ArrayList<>();
for(String month : months){
boolean isHas = false;
for(HiddenStatVO hidden : barData){
if(month.equals(hidden.getMonth())){
isHas = true;
hiddens.add(hidden.getHiddenCount());
rectifieds.add(hidden.getRectifiedCount());
break;
}
}
if(!isHas){
hiddens.add(0);
rectifieds.add(0);
}
}
result.put("months",months);
result.put("hiddens",hiddens);
result.put("rectifieds",rectifieds);
//环状统计图
Map<String,Integer> pieData = tStaningBookMapper.hiddenPieStat(troubleLevel,beginTime,endTime);
List<Map<String,Object>> pieResult = new ArrayList<>();
Map<String,Object> rectifiedMap = new HashMap<>(16);
rectifiedMap.put("name","已整改");
rectifiedMap.put("value",pieData.get("rectifiedCount"));
pieResult.add(rectifiedMap);
Map<String,Object> stayRectifiedMap = new HashMap<>(16);
stayRectifiedMap.put("name","未整改");
stayRectifiedMap.put("value",pieData.get("stayRectifiedCount"));
pieResult.add(stayRectifiedMap);
result.put("pieData",pieResult);
} catch (Exception e) {
logger.error("隐患统计错误:" + e);
}
result.put("months",months);
result.put("hiddens",hiddens);
result.put("rectifieds",rectifieds);
//环状统计图
Map<String,Integer> pieData = tStaningBookMapper.hiddenPieStat(troubleLevel,beginTime,endTime);
List<Map<String,Object>> pieResult = new ArrayList<>();
Map<String,Object> rectifiedMap = new HashMap<>(16);
rectifiedMap.put("name","已整改");
rectifiedMap.put("value",pieData.get("rectifiedCount"));
pieResult.add(rectifiedMap);
Map<String,Object> stayRectifiedMap = new HashMap<>(16);
stayRectifiedMap.put("name","未整改");
stayRectifiedMap.put("value",pieData.get("stayRectifiedCount"));
pieResult.add(stayRectifiedMap);
result.put("pieData",pieResult);
return result;
}
private String changeMonth(int month){
switch (month){
case 1:
return "一月";
case 2:
return "二月";
case 3:
return "三月";
case 4:
return "四月";
case 5:
return "五月";
case 6:
return "六月";
case 7:
return "七月";
case 8:
return "八月";
case 9:
return "九月";
case 10:
return "十月";
case 11:
return "十一月";
default:
return "十二月";
/**
* 获取两个日期之间的所有月份 (年月)
*
* @param startTime
* @param endTime
* @return:YYYY-MM
*/
private List<String> getMonthBetweenDate(Date startTime, Date endTime){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
// 声明保存日期集合
List<String> list = new ArrayList<String>();
//用Calendar 进行日期比较判断
Calendar calendar = Calendar.getInstance();
while (startTime.getTime()<=endTime.getTime()){
// 把日期添加到集合
list.add(sdf.format(startTime));
// 设置日期
calendar.setTime(startTime);
//把日期增加一天
calendar.add(Calendar.MONTH, 1);
// 获取增加后的日期
startTime=calendar.getTime();
}
return list;
}
}
......@@ -199,7 +199,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="hiddenBarStat" resultType="HiddenStatVO">
SELECT
IFNULL(MONTH(find_time),0) AS month,
IFNULL(DATE_FORMAT(find_time,'%Y-%m'),0) AS month,
IFNULL(count(1),0) hiddenCount,
IFNULL(sum(CASE state WHEN '2' THEN 1 ELSE 0 END),0) AS rectifiedCount
FROM
......@@ -212,7 +212,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="troubleLevel != null and troubleLevel != ''">
AND trouble_level = #{troubleLevel}
</if>
GROUP BY MONTH(find_time)
GROUP BY DATE_FORMAT(find_time,'%Y-%m')
</select>
<select id="hiddenPieStat" resultType="java.util.Map">
......
......@@ -462,8 +462,8 @@ export default {
cancelButtonText: "取消",
type: "warning"
}).then(function() {
row.isDel = "1";
return updateContractorPerson(ids);
row.isDel = "1";
return updateContractorPerson(row);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
......
......@@ -2,7 +2,7 @@
<div class="hiddenStat">
<el-form :model="queryParams" :inline="true" label-width="100px" style="margin-top: 10px">
<el-form-item label="隐患级别" prop="hiddenLevel">
<el-select v-model="queryParams.troubleLevel" placeholder="请选择隐患级别">
<el-select v-model="queryParams.troubleLevel" placeholder="请选择隐患级别" clearable>
<el-option
v-for="dict in troubleLevelOptions"
:key="dict.dictValue"
......@@ -50,7 +50,7 @@
closeHiddenBarData: [],
pieData: [],
troubleLevelOptions: [],
findTime: ""
findTime: [new Date().getFullYear() + "-01-01 00:00:00",new Date().getFullYear() + "-12-31 23:59:59"]
}
},
mounted(){
......@@ -75,11 +75,20 @@
},
xAxis: {
type: 'category',
//data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
axisLabel: {
//x轴文字的配置
show: true,
interval: 0,//使x轴文字显示全
rotate: -270
},
//data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
data: this.monthData
},
yAxis: {
type: 'value'
type: 'value',
axisLabel: {
interval: 0,
},
},
series: [
{
......@@ -119,7 +128,7 @@
},
series: [
{
name: 'gun',
name: '隐患整改率',
type: 'pie',
radius: ['40%', '70%'],
/*data: [
......@@ -148,8 +157,14 @@
})
},
dateFormat(picker){
this.queryParams.beginTime = picker[0];
this.queryParams.endTime = picker[1];
if(!picker){
this.findTime = [];
this.queryParams.beginTime = null;
this.queryParams.endTime = null;
}else{
this.queryParams.beginTime = picker[0];
this.queryParams.endTime = picker[1];
}
},
search(){
this.getHiddenData();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment