jfreechart+easyExcel 方式导出报表
18 files modified
4 files added
2 files deleted
| New file |
| | |
| | | package org.springblade.common.converter; |
| | | |
| | | import com.alibaba.excel.converters.Converter; |
| | | import com.alibaba.excel.enums.CellDataTypeEnum; |
| | | import com.alibaba.excel.metadata.CellData; |
| | | import com.alibaba.excel.metadata.GlobalConfiguration; |
| | | import com.alibaba.excel.metadata.property.ExcelContentProperty; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Component |
| | | public class AnimalHeatTypeConverter implements Converter<Integer> { |
| | | @Override |
| | | public Class supportJavaTypeKey() { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public CellDataTypeEnum supportExcelTypeKey() { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public CellData convertToExcelData(Integer integer, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { |
| | | return new CellData(integer.equals(1) ? "异常":"正常"); |
| | | } |
| | | } |
| | |
| | | package org.springblade.common.entity; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnore; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.alibaba.excel.annotation.write.style.ColumnWidth; |
| | | import com.alibaba.excel.annotation.write.style.ContentRowHeight; |
| | | import com.alibaba.excel.annotation.write.style.HeadRowHeight; |
| | | import lombok.Data; |
| | | import org.springblade.common.converter.AnimalHeatTypeConverter; |
| | | |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | |
| | | @ContentRowHeight(18) |
| | | public class AnimalHeatExcel { |
| | | |
| | | @ColumnWidth(15) |
| | | @ColumnWidth(12) |
| | | @ExcelProperty("体温检测编号") |
| | | private Integer id;// bigint(20) NOT NULL COMMENT '主键', |
| | | |
| | |
| | | @ExcelProperty("设备IP") |
| | | private String ip;// varchar(63) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '设备IP地址', |
| | | |
| | | @ColumnWidth(50) |
| | | @ColumnWidth(60) |
| | | @ExcelProperty("图片URL") |
| | | private String picture;// varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '图片url路径', |
| | | |
| | | // @TableField("picture_red") |
| | | // private String pictureRed;// varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '红外图片url路径', |
| | | /** |
| | | * 忽略,不显示到excel |
| | | */ |
| | | @ExcelIgnore |
| | | private String pictureRed;// varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '红外图片url路径', |
| | | |
| | | @ColumnWidth(15) |
| | | @ExcelProperty("体温") |
| | |
| | | @ExcelProperty("创建时间") |
| | | private Date createTime;// datetime DEFAULT NULL COMMENT '创建时间', |
| | | |
| | | @ColumnWidth(25) |
| | | @ExcelProperty("状态 1:异常 0:正常") |
| | | @ColumnWidth(10) |
| | | @ExcelProperty(value = "状态",converter = AnimalHeatTypeConverter.class) |
| | | private Integer status;//状态 1为异常 0为正常 ,以37.3度为标准,大于37.3度为高温 |
| | | } |
| New file |
| | |
| | | package org.springblade.common.entity; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class ReportReturnData { |
| | | private String type; |
| | | private Integer count; |
| | | } |
| | |
| | | List<AlarmExcel> getAlarmList(@RequestBody String body); |
| | | |
| | | /** |
| | | * 获取实时警情图表数据 |
| | | * @param body |
| | | * @return |
| | | */ |
| | | @PostMapping("getAlarmPie") |
| | | List<ReportReturnData> getAlarmPie(@RequestBody String body); |
| | | |
| | | /** |
| | | * 获取健康码数据集合 |
| | | * @param body map集合数据 |
| | | * @return |
| | | */ |
| | | @PostMapping("getHealthcodeList") |
| | | List<HealthcodeExcel> getHealthcodeList(@RequestBody String body); |
| | | |
| | | /** |
| | | * 获取健康码图表数据 |
| | | * @param body map集合数据 |
| | | * @return |
| | | */ |
| | | @PostMapping("getHealthcodePie") |
| | | List<ReportReturnData> getHealthcodePie(@RequestBody String body); |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @PostMapping("getAnimalHeatList") |
| | | List<AnimalHeatExcel> getAnimalHeatList(@RequestBody String body); |
| | | |
| | | /** |
| | | * 获取体温数据集合 |
| | | * @param body map集合数据 |
| | | * @return |
| | | */ |
| | | @PostMapping("getAnimalHeatPie") |
| | | List<ReportReturnData> getAnimalHeatPie(@RequestBody String body); |
| | | |
| | | /** |
| | | * 获取包裹数据集合 |
| | |
| | | */ |
| | | @PostMapping("getParcelKindList") |
| | | List<ParcelKindExcel> getParcelKindList(@RequestBody String body); |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | package org.springblade.report.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import org.springblade.report.service.ReportFileService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | |
| | | |
| | | /** |
| | | * 获取包裹数据集合 |
| | | * 获取实时警情数据集合 |
| | | * @param beanName 调用名称 |
| | | * @param dataName 返回数据名称 |
| | | * @param map map集合数据 |
| | |
| | | String body = JSON.toJSONString(map); |
| | | if (null!=beanName){ |
| | | return reportClient.getAlarmList(body); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 获取实时警情图表数据 |
| | | * @param beanName 调用名称 |
| | | * @param dataName 返回数据名称 |
| | | * @param map map集合数据 |
| | | * @return |
| | | */ |
| | | public List<ReportReturnData> getAlarmPie(String beanName, String dataName, Map<String,Object> map){ |
| | | //将map转换为json对象 |
| | | String body = JSON.toJSONString(map); |
| | | if (null!=beanName){ |
| | | return reportClient.getAlarmPie(body); |
| | | } |
| | | return null; |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取健康码图表数据 |
| | | * @param beanName 调用名称 |
| | | * @param dataName 返回数据名称 |
| | | * @param map map集合数据 |
| | | * @return |
| | | */ |
| | | public List<ReportReturnData> getHealthcodePie(String beanName, String dataName, Map<String,Object> map){ |
| | | //将map转换为json对象 |
| | | String s = JSON.toJSONString(map); |
| | | if (null!=beanName){ |
| | | return reportClient.getHealthcodePie(s); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 获取体温数据集合 |
| | | * @param beanName 调用名称 |
| | | * @param dataName 返回数据名称 |
| | |
| | | //将map转换为json对象 |
| | | String body = JSON.toJSONString(map); |
| | | if (null!=beanName){ |
| | | System.out.println("reportClient.getAnimalHeatList(body) = " + reportClient.getAnimalHeatList(body)); |
| | | return reportClient.getAnimalHeatList(body); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 获取体温数据集合 |
| | | * @param beanName 调用名称 |
| | | * @param dataName 返回数据名称 |
| | | * @param map map集合数据 |
| | | * @return |
| | | */ |
| | | @PostMapping("getAnimalHeatPie") |
| | | public List<ReportReturnData> getAnimalHeatPie(String beanName, String dataName, Map<String,Object> map){ |
| | | //将map转换为json对象 |
| | | String body = JSON.toJSONString(map); |
| | | if (null!=beanName){ |
| | | System.out.println("reportClient = " + reportClient.getAnimalHeatPie(body)); |
| | | return reportClient.getAnimalHeatPie(body); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 获取包裹数据集合 |
| | | * @param beanName 调用名称 |
| | | * @param dataName 返回数据名称 |
| | |
| | | <artifactId>FFmpeg-windows-x86_64</artifactId> |
| | | <version>2.0.1.1</version> |
| | | </dependency> |
| | | <!--用于生成图片 --> |
| | | <dependency> |
| | | <groupId>org.jfree</groupId> |
| | | <artifactId>jfreechart</artifactId> |
| | | <version>1.0.19</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springblade.common.entity.ReportReturnData; |
| | | import org.springblade.jfpt.alarm.entity.Alarm; |
| | | import org.springblade.common.entity.AlarmExcel; |
| | | import org.springblade.jfpt.alarm.vo.AlarmVO; |
| | |
| | | * @param alarmVO 查询条件 |
| | | */ |
| | | List<AlarmExcel> exportAlarm(@Param("alarm")AlarmVO alarmVO); |
| | | |
| | | /** |
| | | * 获取实时警情图表统计数据 |
| | | * @param alarmVO |
| | | * @return |
| | | */ |
| | | List<ReportReturnData> getAlarmPie(@Param("alarm")AlarmVO alarmVO); |
| | | } |
| | |
| | | <result column="aaddress" property="aaddress"/> |
| | | </resultMap> |
| | | |
| | | |
| | | <select id="selectAlarmPage" resultMap="alarmResultMap"> |
| | | select |
| | | a.id,a.alarmType,a.alarmPeople,a.alarmTime,a.galarmPeople,a.sex,a.phoneNumber,a.place,a.content,a.waringType,a.bz, |
| | | a.deviceNumber,a.region,a.district,a.vaddress,a.aaddress, |
| | | a.alarmId,a.LEVEL,e.jd,e.wd,a.jtype,a.rname,a.jjTime,a.province,a.city,a.cid, |
| | | e.serialNumber,e.oneContacts,e.ThreeContacts,e.twoContacts,e.onePhone,e.twoPhone,e.ThreePhone, |
| | | e.stype, |
| | | e.oneId, |
| | | e.twoId, |
| | | e.threeId, |
| | | e.deptId, |
| | | e.channelNumber from sys_alarm a |
| | | LEFT JOIN sys_equipment e on e.deviceNumber=a.deviceNumber |
| | | where 1=1 |
| | | <sql id="alarmCondition"> |
| | | <if test="alarm.jtype!=null"> |
| | | and a.jtype like concat('%',#{alarm.jtype},'%') |
| | | </if> |
| | |
| | | and hour(alarmTime)>=22 and hour(alarmTime) <24 |
| | | </if> |
| | | </if> |
| | | </sql> |
| | | <sql id="alarmConditionPie"> |
| | | <if test="alarm.beginTime!=null and alarm.beginTime!=''"> |
| | | and alarmTime>=#{alarm.beginTime} |
| | | </if> |
| | | <if test="alarm.endTime!=null and alarm.endTime!=''"> |
| | | and alarmTime<=#{alarm.endTime} |
| | | </if> |
| | | <if test="alarm.timeDesc!=null and alarm.timeDesc!=''"> |
| | | <if test="alarm.timeDesc=='30分钟以上'"> |
| | | and czTime-alarmTime>1800 |
| | | </if> |
| | | <if test="alarm.timeDesc=='10-30分钟'"> |
| | | and czTime-alarmTime>600 and czTime-alarmTime <1800 |
| | | </if> |
| | | <if test="alarm.timeDesc=='5-10分钟'"> |
| | | and czTime-alarmTime>300 and czTime-alarmTime <600 |
| | | </if> |
| | | <if test="alarm.timeDesc=='小于5分钟'"> |
| | | and czTime-alarmTime>0 and czTime-alarmTime <300 |
| | | </if> |
| | | <if test="alarm.timeDesc=='0-2'"> |
| | | and hour(alarmTime)>=0 and hour(alarmTime) <2 |
| | | </if> |
| | | <if test="alarm.timeDesc=='2-4'"> |
| | | and hour(alarmTime)>=2 and hour(alarmTime) <4 |
| | | </if> |
| | | <if test="alarm.timeDesc=='4-6'"> |
| | | and hour(alarmTime)>=4 and hour(alarmTime) <6 |
| | | </if> |
| | | <if test="alarm.timeDesc=='6-8'"> |
| | | and hour(alarmTime)>=6 and hour(alarmTime) <8 |
| | | </if> |
| | | <if test="alarm.timeDesc=='8-10'"> |
| | | and hour(alarmTime)>=8 and hour(alarmTime) <10 |
| | | </if> |
| | | <if test="alarm.timeDesc=='10-12'"> |
| | | and hour(alarmTime)>=10 and hour(alarmTime) <12 |
| | | </if> |
| | | <if test="alarm.timeDesc=='12-14'"> |
| | | and hour(alarmTime)>=12 and hour(alarmTime) <14 |
| | | </if> |
| | | <if test="alarm.timeDesc=='14-16'"> |
| | | and hour(alarmTime)>=14 and hour(alarmTime) <16 |
| | | </if> |
| | | <if test="alarm.timeDesc=='16-18'"> |
| | | and hour(alarmTime)>=16 and hour(alarmTime) <18 |
| | | </if> |
| | | <if test="alarm.timeDesc=='18-20'"> |
| | | and hour(alarmTime)>=18 and hour(alarmTime) <20 |
| | | </if> |
| | | <if test="alarm.timeDesc=='20-22'"> |
| | | and hour(alarmTime)>=20 and hour(alarmTime) <22 |
| | | </if> |
| | | <if test="alarm.timeDesc=='22-24'"> |
| | | and hour(alarmTime)>=22 and hour(alarmTime) <24 |
| | | </if> |
| | | </if> |
| | | </sql> |
| | | |
| | | |
| | | <select id="selectAlarmPage" resultMap="alarmResultMap"> |
| | | select |
| | | a.id,a.alarmType,a.alarmPeople,a.alarmTime,a.galarmPeople,a.sex,a.phoneNumber,a.place,a.content,a.waringType,a.bz, |
| | | a.deviceNumber,a.region,a.district,a.vaddress,a.aaddress, |
| | | a.alarmId,a.LEVEL,e.jd,e.wd,a.jtype,a.rname,a.jjTime,a.province,a.city,a.cid, |
| | | e.serialNumber,e.oneContacts,e.ThreeContacts,e.twoContacts,e.onePhone,e.twoPhone,e.ThreePhone, |
| | | e.stype, |
| | | e.oneId, |
| | | e.twoId, |
| | | e.threeId, |
| | | e.deptId, |
| | | e.channelNumber from sys_alarm a |
| | | LEFT JOIN sys_equipment e on e.deviceNumber=a.deviceNumber |
| | | where 1=1 |
| | | <include refid="alarmCondition"></include> |
| | | and a.waringType IN("紧急求救") |
| | | |
| | | ORDER BY |
| | | a.jtype ASC, |
| | | a.alarmTime DESC |
| | |
| | | from sys_alarm a |
| | | LEFT JOIN sys_equipment e on e.deviceNumber=a.deviceNumber |
| | | where 1=1 |
| | | <if test="alarm.jtype!=null"> |
| | | and a.jtype like concat('%',#{alarm.jtype},'%') |
| | | </if> |
| | | <if test="alarm.deviceNumber!=null"> |
| | | and a.deviceNumber like concat('%',#{alarm.deviceNumber},'%') |
| | | </if> |
| | | <if test="alarm.galarmPeople!=null"> |
| | | and a.galarmPeople like concat('%',#{alarm.galarmPeople},'%') |
| | | </if> |
| | | <if test="alarm.district!=null"> |
| | | and a.district like concat('%',#{alarm.district},'%') |
| | | </if> |
| | | <if test="alarm.province!=null"> |
| | | and a.province like concat('%',#{alarm.province},'%') |
| | | </if> |
| | | <if test="alarm.city!=null"> |
| | | and a.city like concat('%',#{alarm.city},'%') |
| | | </if> |
| | | <if test="alarm.level!=null"> |
| | | and a.level like concat('%',#{alarm.level},'%') |
| | | </if> |
| | | <if test="alarm.waringType!=null"> |
| | | and a.waringType like concat('%',#{alarm.waringType},'%') |
| | | </if> |
| | | <if test="alarm.beginTime!=null and alarm.beginTime!=''"> |
| | | and a.alarmTime>=#{alarm.beginTime} |
| | | </if> |
| | | <if test="alarm.endTime!=null and alarm.endTime!=''"> |
| | | and a.alarmTime<=#{alarm.endTime} |
| | | </if> |
| | | <if test="alarm.timeDesc!=null and alarm.timeDesc!=''"> |
| | | <if test="alarm.timeDesc=='30分钟以上'"> |
| | | and czTime-alarmTime>1800 |
| | | </if> |
| | | <if test="alarm.timeDesc=='10-30分钟'"> |
| | | and czTime-alarmTime>600 and czTime-alarmTime <1800 |
| | | </if> |
| | | <if test="alarm.timeDesc=='5-10分钟'"> |
| | | and czTime-alarmTime>300 and czTime-alarmTime <600 |
| | | </if> |
| | | <if test="alarm.timeDesc=='小于5分钟'"> |
| | | and czTime-alarmTime>0 and czTime-alarmTime <300 |
| | | </if> |
| | | <if test="alarm.timeDesc=='0-2'"> |
| | | and hour(alarmTime)>=0 and hour(alarmTime) <2 |
| | | </if> |
| | | <if test="alarm.timeDesc=='2-4'"> |
| | | and hour(alarmTime)>=2 and hour(alarmTime) <4 |
| | | </if> |
| | | <if test="alarm.timeDesc=='4-6'"> |
| | | and hour(alarmTime)>=4 and hour(alarmTime) <6 |
| | | </if> |
| | | <if test="alarm.timeDesc=='6-8'"> |
| | | and hour(alarmTime)>=6 and hour(alarmTime) <8 |
| | | </if> |
| | | <if test="alarm.timeDesc=='8-10'"> |
| | | and hour(alarmTime)>=8 and hour(alarmTime) <10 |
| | | </if> |
| | | <if test="alarm.timeDesc=='10-12'"> |
| | | and hour(alarmTime)>=10 and hour(alarmTime) <12 |
| | | </if> |
| | | <if test="alarm.timeDesc=='12-14'"> |
| | | and hour(alarmTime)>=12 and hour(alarmTime) <14 |
| | | </if> |
| | | <if test="alarm.timeDesc=='14-16'"> |
| | | and hour(alarmTime)>=14 and hour(alarmTime) <16 |
| | | </if> |
| | | <if test="alarm.timeDesc=='16-18'"> |
| | | and hour(alarmTime)>=16 and hour(alarmTime) <18 |
| | | </if> |
| | | <if test="alarm.timeDesc=='18-20'"> |
| | | and hour(alarmTime)>=18 and hour(alarmTime) <20 |
| | | </if> |
| | | <if test="alarm.timeDesc=='20-22'"> |
| | | and hour(alarmTime)>=20 and hour(alarmTime) <22 |
| | | </if> |
| | | <if test="alarm.timeDesc=='22-24'"> |
| | | and hour(alarmTime)>=22 and hour(alarmTime) <24 |
| | | </if> |
| | | </if> |
| | | |
| | | <include refid="alarmCondition"></include> |
| | | and a.waringType IN("紧急求救") |
| | | |
| | | ORDER BY |
| | | a.jtype ASC, |
| | | a.alarmTime DESC |
| | | </select> |
| | | |
| | | <!--获取实时警情图表统计数据--> |
| | | <select id="getAlarmPie" resultType="org.springblade.common.entity.ReportReturnData"> |
| | | select if(1=1,"紧急求救",0) type,ifnull(count(*),0) count from sys_alarm |
| | | where waringType="紧急求救" |
| | | <include refid="alarmConditionPie"></include> |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.common.entity.ReportReturnData; |
| | | import org.springblade.jfpt.alarm.entity.Alarm; |
| | | import org.springblade.common.entity.AlarmExcel; |
| | | import org.springblade.jfpt.alarm.vo.AlarmVO; |
| | |
| | | * @param alarmVO 查询条件 |
| | | */ |
| | | List<AlarmExcel> exportAlarm(AlarmVO alarmVO); |
| | | |
| | | /** |
| | | * 获取实时警情数据集合 |
| | | * @param alarmVO |
| | | * @return |
| | | */ |
| | | List<ReportReturnData> getAlarmPie(AlarmVO alarmVO); |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.common.entity.ReportReturnData; |
| | | import org.springblade.jfpt.alarm.constant.AlarmTimeConstant; |
| | | import org.springblade.jfpt.alarm.entity.Alarm; |
| | | import org.springblade.jfpt.alarm.mapper.AlarmMapper; |
| | |
| | | public List<AlarmExcel> exportAlarm(AlarmVO alarmVO) { |
| | | return baseMapper.exportAlarm(alarmVO); |
| | | } |
| | | |
| | | /** |
| | | * 获取实时警情数据集合 |
| | | * @param alarmVO |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<ReportReturnData> getAlarmPie(AlarmVO alarmVO) { |
| | | return baseMapper.getAlarmPie(alarmVO); |
| | | } |
| | | } |
| | |
| | | package org.springblade.jfpt.animalheat.controller; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.EasyExcelFactory; |
| | | import com.alibaba.excel.ExcelWriter; |
| | | import com.alibaba.excel.write.metadata.WriteSheet; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.commons.codec.Charsets; |
| | | import org.jfree.chart.ChartFactory; |
| | | import org.jfree.chart.ChartUtilities; |
| | | import org.jfree.chart.JFreeChart; |
| | | import org.jfree.chart.labels.StandardPieSectionLabelGenerator; |
| | | import org.jfree.chart.plot.PiePlot; |
| | | import org.jfree.data.general.DefaultPieDataset; |
| | | import org.springblade.common.entity.ReportReturnData; |
| | | import org.springblade.core.excel.util.ExcelUtil; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | |
| | | import org.springblade.jfpt.animalheat.entity.BladeAnimalHeat; |
| | | import org.springblade.jfpt.animalheat.service.AnimalHeatService; |
| | | import org.springblade.jfpt.animalheat.vo.AnimalHeatVo; |
| | | import org.springblade.jfpt.pie.ImageData; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.awt.*; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @GetMapping("/export-animalHeat") |
| | | public void exportAnimalHeat(AnimalHeatVo animalHeatVo,HttpServletResponse response){ |
| | | List<AnimalHeatExcel> list = animalHeatService.exportAnimalHeat(animalHeatVo); |
| | | ExcelUtil.export(response, "体温检测数据" + DateUtil.time(), "体温检测数据表", list, AnimalHeatExcel.class); |
| | | ExcelUtil.export(response, "体温检测数据" + DateUtil.time(), "体温检测数据表", list,AnimalHeatExcel.class ); |
| | | } |
| | | |
| | | /** |
| | | * 导出体温数据列表 |
| | | * @param animalHeatVo 条件 |
| | | * @param response 返回域 |
| | | */ |
| | | @GetMapping("/getAnimalHeatStatis") |
| | | public void getAnimalHeatStatis(AnimalHeatVo animalHeatVo,HttpServletResponse response){ |
| | | //获取统计数据 |
| | | List<AnimalHeatExcel> animalHeatExcels = animalHeatService.exportAnimalHeat(animalHeatVo); |
| | | List<ReportReturnData> reportReturnData = animalHeatService.getAnimalHeatPie(animalHeatVo); |
| | | |
| | | //创建jfreechart 画图对象 |
| | | DefaultPieDataset pds = new DefaultPieDataset(); |
| | | |
| | | //遍历统计数据,将数据保存到饼图对象中 |
| | | for (ReportReturnData returnData:reportReturnData) { |
| | | pds.setValue(returnData.getType(),returnData.getCount()); |
| | | } |
| | | |
| | | //声明excelWriter对象 |
| | | ExcelWriter excelWriter = null; |
| | | try { |
| | | // 分别是:显示图表的标题、需要提供对应图表的DateSet对象、是否显示图例、是否生成贴士以及是否生成URL链接 |
| | | JFreeChart chart = ChartFactory.createPieChart("体温数据统计图", pds, false, false, true); |
| | | // 如果不使用Font,中文将显示不出来 |
| | | Font font = new Font("宋体", Font.BOLD, 24); |
| | | // 设置图片标题的字体 |
| | | chart.getTitle().setFont(font); |
| | | // 得到图块,准备设置标签的字体 |
| | | PiePlot plot = (PiePlot) chart.getPlot(); |
| | | // 设置标签字体 |
| | | plot.setLabelFont(font); |
| | | plot.setStartAngle(new Float(3.14f / 2f)); |
| | | // 设置plot的前景色透明度 |
| | | plot.setForegroundAlpha(0.7f); |
| | | // 设置plot的背景色透明度 |
| | | plot.setBackgroundAlpha(0.0f); |
| | | // 设置标签生成器(默认{0}) |
| | | // {0}:key {1}:value {2}:百分比 {3}:sum |
| | | plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}({1}占{2})")); |
| | | ByteArrayOutputStream bos = new ByteArrayOutputStream(); |
| | | |
| | | //创建图片数据集合,对象 |
| | | ArrayList<ImageData> imageDatas = new ArrayList<>(); |
| | | ImageData imageData = new ImageData(); |
| | | try { |
| | | // 将图表写入到ByteArrayOutputStream流中 |
| | | ChartUtilities.writeChartAsJPEG(bos, chart, 800, 700); |
| | | //将字节数组输出流写入到输入流中 |
| | | InputStream inputStream = new ByteArrayInputStream(bos.toByteArray()); |
| | | //excel 文件名称 |
| | | String fileName = "体温统计报表" + System.currentTimeMillis() + ".xlsx"; |
| | | //封装数据到图表 |
| | | imageData.setInputStream(inputStream); |
| | | imageDatas.add(imageData); |
| | | |
| | | //设置响应体 |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding(Charsets.UTF_8.name()); |
| | | fileName = URLEncoder.encode(fileName, Charsets.UTF_8.name()); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | //写入 |
| | | excelWriter = EasyExcel.write(response.getOutputStream()).build(); |
| | | |
| | | //shell0 |
| | | WriteSheet writeSheet = EasyExcel.writerSheet(0, "图表").head(ImageData.class).build(); |
| | | excelWriter.write(imageDatas, writeSheet); |
| | | |
| | | //shell1 |
| | | WriteSheet writeSheet0 = EasyExcel.writerSheet(1, "数据列表").head(AnimalHeatExcel.class).build(); |
| | | excelWriter.write(animalHeatExcels, writeSheet0); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | }finally { |
| | | //完成后会关闭流 |
| | | excelWriter.finish(); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springblade.common.entity.ReportReturnData; |
| | | import org.springblade.jfpt.animalheat.entity.BladeAnimalHeat; |
| | | import org.springblade.common.entity.AnimalHeatExcel; |
| | | import org.springblade.jfpt.animalheat.vo.AnimalHeatVo; |
| | |
| | | * @param animalHeatVo 条件 |
| | | */ |
| | | List<AnimalHeatExcel> exportAnimalHeat(@Param("animalHeatVo")AnimalHeatVo animalHeatVo); |
| | | |
| | | /** |
| | | * 导出体温数据列表 |
| | | * @param animalHeatVo 条件 |
| | | */ |
| | | List<ReportReturnData> getAnimalHeatPie(@Param("animalHeatVo")AnimalHeatVo animalHeatVo); |
| | | } |
| | |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.springblade.jfpt.animalheat.mapper.AnimalHeatMapper"> |
| | | |
| | | <!--查询当天体温数据统计--> |
| | | <select id="getAnimalStatis" resultType="java.util.HashMap"> |
| | | SELECT 1 `name`,count(`status`) value FROM `blade_animal_heat` where |
| | | TO_DAYS(create_time)=TO_DAYS(now()) and `status`=1 |
| | | UNION |
| | | SELECT 0 `name`,count(`status`) value FROM `blade_animal_heat` where |
| | | TO_DAYS(create_time)=TO_DAYS(now()) and `status`=0 |
| | | </select> |
| | | |
| | | <!--获取本周的体温统计数据--> |
| | | <select id="getAnimalStatisWeek" resultType="java.util.HashMap"> |
| | | SELECT 1 `name`,count(`status`) value FROM `blade_animal_heat` where |
| | | YEARWEEK(date_format(create_time,'%Y-%m-%d'),1) = YEARWEEK(now(),1) and `status`=1 |
| | | UNION |
| | | SELECT 0 `name`,count(`status`) value FROM `blade_animal_heat` where |
| | | YEARWEEK(date_format(create_time,'%Y-%m-%d'),1) = YEARWEEK(now(),1) and `status`=0 |
| | | </select> |
| | | |
| | | <!--获取本月的体温统计数据--> |
| | | <select id="getAnimalStatisMonth" resultType="java.util.HashMap"> |
| | | SELECT 1 `name`,count(`status`) value FROM `blade_animal_heat` where |
| | | date_format(create_time,'%Y%m') = date_format(now(),'%Y%m') and `status`=1 |
| | | UNION |
| | | SELECT 0 `name`,count(`status`) value FROM `blade_animal_heat` where |
| | | date_format(create_time,'%Y%m') = date_format(now(),'%Y%m') and `status`=0 |
| | | </select> |
| | | |
| | | <!--查询体温数据的分页数据--> |
| | | <select id="selectAnimalHeatPageList" resultType="org.springblade.jfpt.animalheat.entity.BladeAnimalHeat"> |
| | | SELECT * FROM blade_animal_heat |
| | | where 1=1 |
| | | <sql id="animalHeatCondition"> |
| | | <if test="animalHeatVo.type==0"> |
| | | and to_days(create_time)=to_days(now()) |
| | | </if> |
| | |
| | | </if> |
| | | <if test="animalHeatVo.type==2"> |
| | | and date_format(create_time,'%Y%m') = date_format(now(),'%Y%m') |
| | | </if> |
| | | <if test="animalHeatVo.status!=null"> |
| | | and status=#{animalHeatVo.status} |
| | | </if> |
| | | <if test="animalHeatVo.begTime!=null and animalHeatVo.begTime!='' and animalHeatVo.endTime!=null and animalHeatVo.endTime!='' "> |
| | | and date(create_time) between #{animalHeatVo.begTime} and #{animalHeatVo.endTime} |
| | |
| | | and hour(create_time)>=22 and hour(create_time) <24 |
| | | </if> |
| | | </if> |
| | | </sql> |
| | | |
| | | <!--查询当天体温数据统计--> |
| | | <select id="getAnimalStatis" resultType="java.util.HashMap"> |
| | | SELECT 1 `name`,count(`status`) value FROM `blade_animal_heat` where |
| | | TO_DAYS(create_time)=TO_DAYS(now()) and `status`=1 |
| | | UNION |
| | | SELECT 0 `name`,count(`status`) value FROM `blade_animal_heat` where |
| | | TO_DAYS(create_time)=TO_DAYS(now()) and `status`=0 |
| | | </select> |
| | | |
| | | <!--获取本周的体温统计数据--> |
| | | <select id="getAnimalStatisWeek" resultType="java.util.HashMap"> |
| | | SELECT 1 `name`,count(`status`) value FROM `blade_animal_heat` where |
| | | YEARWEEK(date_format(create_time,'%Y-%m-%d'),1) = YEARWEEK(now(),1) and `status`=1 |
| | | UNION |
| | | SELECT 0 `name`,count(`status`) value FROM `blade_animal_heat` where |
| | | YEARWEEK(date_format(create_time,'%Y-%m-%d'),1) = YEARWEEK(now(),1) and `status`=0 |
| | | </select> |
| | | |
| | | <!--获取本月的体温统计数据--> |
| | | <select id="getAnimalStatisMonth" resultType="java.util.HashMap"> |
| | | SELECT 1 `name`,count(`status`) value FROM `blade_animal_heat` where |
| | | date_format(create_time,'%Y%m') = date_format(now(),'%Y%m') and `status`=1 |
| | | UNION |
| | | SELECT 0 `name`,count(`status`) value FROM `blade_animal_heat` where |
| | | date_format(create_time,'%Y%m') = date_format(now(),'%Y%m') and `status`=0 |
| | | </select> |
| | | |
| | | <!--查询体温数据的分页数据--> |
| | | <select id="selectAnimalHeatPageList" resultType="org.springblade.jfpt.animalheat.entity.BladeAnimalHeat"> |
| | | SELECT * FROM blade_animal_heat |
| | | where 1=1 |
| | | <if test="animalHeatVo.status!=null"> |
| | | and status=#{animalHeatVo.status} |
| | | </if> |
| | | <include refid="animalHeatCondition"></include> |
| | | ORDER BY create_time desc |
| | | </select> |
| | | |
| | |
| | | <select id="exportAnimalHeat" resultType="org.springblade.common.entity.AnimalHeatExcel"> |
| | | SELECT * FROM blade_animal_heat |
| | | where 1=1 |
| | | <if test="animalHeatVo.type==0"> |
| | | and to_days(create_time)=to_days(now()) |
| | | </if> |
| | | <if test="animalHeatVo.type==1"> |
| | | and YEARWEEK(date_format(create_time,'%Y-%m-%d'),1) = YEARWEEK(now(),1) |
| | | </if> |
| | | <if test="animalHeatVo.type==2"> |
| | | and date_format(create_time,'%Y%m') = date_format(now(),'%Y%m') |
| | | </if> |
| | | <if test="animalHeatVo.status!=null"> |
| | | and status=#{animalHeatVo.status} |
| | | </if> |
| | | <if test="animalHeatVo.begTime!=null and animalHeatVo.begTime!='' and animalHeatVo.endTime!=null and animalHeatVo.endTime!='' "> |
| | | and date(create_time) between #{animalHeatVo.begTime} and #{animalHeatVo.endTime} |
| | | </if> |
| | | <if test="animalHeatVo.timeDesc!=null and animalHeatVo.timeDesc!=''"> |
| | | <if test="animalHeatVo.timeDesc=='0-2'"> |
| | | and hour(create_time)>=0 and hour(create_time) <2 |
| | | </if> |
| | | <if test="animalHeatVo.timeDesc=='2-4'"> |
| | | and hour(create_time)>=2 and hour(create_time) <4 |
| | | </if> |
| | | <if test="animalHeatVo.timeDesc=='4-6'"> |
| | | and hour(create_time)>=4 and hour(create_time) <6 |
| | | </if> |
| | | <if test="animalHeatVo.timeDesc=='6-8'"> |
| | | and hour(create_time)>=6 and hour(create_time) <8 |
| | | </if> |
| | | <if test="animalHeatVo.timeDesc=='8-10'"> |
| | | and hour(create_time)>=8 and hour(create_time) <10 |
| | | </if> |
| | | <if test="animalHeatVo.timeDesc=='10-12'"> |
| | | and hour(create_time)>=10 and hour(create_time) <12 |
| | | </if> |
| | | <if test="animalHeatVo.timeDesc=='12-14'"> |
| | | and hour(create_time)>=12 and hour(create_time) <14 |
| | | </if> |
| | | <if test="animalHeatVo.timeDesc=='14-16'"> |
| | | and hour(create_time)>=14 and hour(create_time) <16 |
| | | </if> |
| | | <if test="animalHeatVo.timeDesc=='16-18'"> |
| | | and hour(create_time)>=16 and hour(create_time) <18 |
| | | </if> |
| | | <if test="animalHeatVo.timeDesc=='18-20'"> |
| | | and hour(create_time)>=18 and hour(create_time) <20 |
| | | </if> |
| | | <if test="animalHeatVo.timeDesc=='20-22'"> |
| | | and hour(create_time)>=20 and hour(create_time) <22 |
| | | </if> |
| | | <if test="animalHeatVo.timeDesc=='22-24'"> |
| | | and hour(create_time)>=22 and hour(create_time) <24 |
| | | </if> |
| | | </if> |
| | | <include refid="animalHeatCondition"></include> |
| | | ORDER BY create_time desc |
| | | </select> |
| | | |
| | | <select id="getAnimalHeatPie" resultType="org.springblade.common.entity.ReportReturnData"> |
| | | select if(1=1,'正常',0) type,ifnull(count(*),0) count from blade_animal_heat where status=0 |
| | | <include refid="animalHeatCondition"></include> |
| | | union all |
| | | select if(1=1,'异常',0) type,ifnull(count(*),0) count from blade_animal_heat where status=1 |
| | | <include refid="animalHeatCondition"></include> |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.common.entity.ReportReturnData; |
| | | import org.springblade.jfpt.animalheat.entity.BladeAnimalHeat; |
| | | import org.springblade.common.entity.AnimalHeatExcel; |
| | | import org.springblade.jfpt.animalheat.vo.AnimalHeatVo; |
| | |
| | | List<AnimalHeatExcel> exportAnimalHeat(AnimalHeatVo animalHeatVo); |
| | | |
| | | |
| | | /** |
| | | * 导出体温数据列表 |
| | | * @param animalHeatVo 条件 |
| | | */ |
| | | List<ReportReturnData> getAnimalHeatPie(AnimalHeatVo animalHeatVo); |
| | | } |
| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.common.entity.ReportReturnData; |
| | | import org.springblade.jfpt.alarm.constant.AlarmTimeConstant; |
| | | import org.springblade.jfpt.animalheat.entity.BladeAnimalHeat; |
| | | import org.springblade.jfpt.animalheat.mapper.AnimalHeatMapper; |
| | |
| | | return baseMapper.exportAnimalHeat(animalHeatVo); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导出体温数据列表 |
| | | * @param animalHeatVo 条件 |
| | | */ |
| | | @Override |
| | | public List<ReportReturnData> getAnimalHeatPie(AnimalHeatVo animalHeatVo) { |
| | | return baseMapper.getAnimalHeatPie(animalHeatVo); |
| | | } |
| | | } |
| | |
| | | public List<AlarmExcel> getAlarmList(@RequestBody String body){ |
| | | Map<String,Object> map = JSONObject.parseObject(body); |
| | | //创建对象,并封装数据 |
| | | AlarmVO alarmVO = getAlarmVO(map); |
| | | //查询数据并返回数据 |
| | | List<AlarmExcel> excelList = iAlarmService.exportAlarm(alarmVO); |
| | | return excelList; |
| | | } |
| | | |
| | | /** |
| | | * 获取实时警情数据集合 |
| | | * @param body map集合数据 |
| | | * @return |
| | | */ |
| | | @PostMapping("getAlarmPie") |
| | | public List<ReportReturnData> getAlarmPie(@RequestBody String body){ |
| | | Map<String,Object> map = JSONObject.parseObject(body); |
| | | //创建对象,并封装数据 |
| | | AlarmVO alarmVO = getAlarmVO(map); |
| | | //查询数据并返回数据 |
| | | List<ReportReturnData> excelList = iAlarmService.getAlarmPie(alarmVO); |
| | | return excelList; |
| | | } |
| | | |
| | | /** |
| | | * 封装实时警情查询条件 |
| | | * @param map |
| | | * @return |
| | | */ |
| | | private AlarmVO getAlarmVO(Map<String, Object> map) { |
| | | AlarmVO alarmVO = new AlarmVO(); |
| | | if (null!=map.get("beginTime")) { |
| | | alarmVO.setBeginTime(map.get("beginTime").toString()); |
| | |
| | | if (null!=map.get("timeDesc")) { |
| | | alarmVO.setTimeDesc(map.get("timeDesc").toString()); |
| | | } |
| | | //查询数据并返回数据 |
| | | List<AlarmExcel> excelList = iAlarmService.exportAlarm(alarmVO); |
| | | return excelList; |
| | | return alarmVO; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取健康码数据集合 |
| | |
| | | public List<HealthcodeExcel> getHealthcodeList(@RequestBody String body){ |
| | | Map<String,Object> map = JSONObject.parseObject(body); |
| | | //创建对象,并封装数据 |
| | | HealthcodeVO healthcodeVO = getHealthcodeVo(map); |
| | | //查询数据并返回数据 |
| | | List<HealthcodeExcel> excelList = ihealthcodeService.exportHealthcode(healthcodeVO); |
| | | return excelList; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取健康码图标数据 |
| | | * @param body map集合数据 |
| | | * @return |
| | | */ |
| | | @PostMapping("getHealthcodePie") |
| | | public List<HealthcodeExcel> getHealthcodePie(@RequestBody String body){ |
| | | Map<String,Object> map = JSONObject.parseObject(body); |
| | | //创建对象,并封装数据 |
| | | HealthcodeVO healthcodeVO = getHealthcodeVo(map); |
| | | //查询数据并返回数据 |
| | | List<HealthcodeExcel> excelList = ihealthcodeService.getHealthcodePie(healthcodeVO); |
| | | return excelList; |
| | | } |
| | | |
| | | /** |
| | | * 封装健康码条件数据 |
| | | * @param map |
| | | * @return |
| | | */ |
| | | private HealthcodeVO getHealthcodeVo(Map<String, Object> map) { |
| | | HealthcodeVO healthcodeVO = new HealthcodeVO(); |
| | | if (null!=map.get("begTime")) { |
| | | healthcodeVO.setBegTime(map.get("begTime").toString()); |
| | |
| | | if (null!=map.get("timeDesc")) { |
| | | healthcodeVO.setTimeDesc(map.get("timeDesc").toString()); |
| | | } |
| | | //查询数据并返回数据 |
| | | List<HealthcodeExcel> excelList = ihealthcodeService.exportHealthcode(healthcodeVO); |
| | | return excelList; |
| | | return healthcodeVO; |
| | | } |
| | | |
| | | /** |
| | |
| | | public List<AnimalHeatExcel> getAnimalHeatList(@RequestBody String body){ |
| | | Map<String,Object> map = JSONObject.parseObject(body); |
| | | //创建对象,并封装数据 |
| | | AnimalHeatVo animalHeatVo = getAnimalHeatVo(map); |
| | | //查询数据并返回数据 |
| | | List<AnimalHeatExcel> excelList = animalHeatService.exportAnimalHeat(animalHeatVo); |
| | | return excelList; |
| | | } |
| | | |
| | | /** |
| | | * 获取体温图表数据 |
| | | * @param body map集合数据 |
| | | * @return |
| | | */ |
| | | @PostMapping("getAnimalHeatPie") |
| | | public List<ReportReturnData> getAnimalHeatPie(@RequestBody String body){ |
| | | Map<String,Object> map = JSONObject.parseObject(body); |
| | | //创建对象,并封装数据 |
| | | AnimalHeatVo animalHeatVo = getAnimalHeatVo(map); |
| | | //查询数据并返回数据 |
| | | List<ReportReturnData> reportReturnData = animalHeatService.getAnimalHeatPie(animalHeatVo); |
| | | System.out.println("reportReturnData = " + reportReturnData); |
| | | return reportReturnData; |
| | | } |
| | | |
| | | /** |
| | | * 体温数据条件封装 |
| | | * @param map |
| | | * @return |
| | | */ |
| | | private AnimalHeatVo getAnimalHeatVo(Map<String, Object> map) { |
| | | AnimalHeatVo animalHeatVo = new AnimalHeatVo(); |
| | | if (null!=map.get("begTime")) { |
| | | animalHeatVo.setBegTime(map.get("begTime").toString()); |
| | |
| | | if (null!=map.get("timeDesc")) { |
| | | animalHeatVo.setTimeDesc(map.get("timeDesc").toString()); |
| | | } |
| | | //查询数据并返回数据 |
| | | List<AnimalHeatExcel> excelList = animalHeatService.exportAnimalHeat(animalHeatVo); |
| | | return excelList; |
| | | return animalHeatVo; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param healthcodeVO 查询条件 |
| | | */ |
| | | List<HealthcodeExcel> exportHealthcode(@Param("healthcodeVO")HealthcodeVO healthcodeVO); |
| | | |
| | | /** |
| | | * 获取健康码图标数据 |
| | | * @param healthcodeVO 查询条件 |
| | | * @return |
| | | */ |
| | | List<HealthcodeExcel> getHealthcodePie(@Param("healthcodeVO")HealthcodeVO healthcodeVO); |
| | | } |
| | |
| | | </if> |
| | | </trim> |
| | | </sql> |
| | | |
| | | <sql id="detailCondition"> |
| | | <if test="healthcodeVO.status==0"> |
| | | and to_days(dtime)=to_days(now()) |
| | | </if> |
| | | <if test="healthcodeVO.status==1"> |
| | | and YEARWEEK(date_format(dtime,'%Y-%m-%d'),1) = YEARWEEK(now(),1) |
| | | </if> |
| | | <if test="healthcodeVO.status==2"> |
| | | and date_format(dtime,'%Y%m') = date_format(now(),'%Y%m') |
| | | </if> |
| | | <if test="healthcodeVO.province!=null"> |
| | | and province like concat('%',#{healthcodeVO.province},'%') |
| | | </if> |
| | | <if test="healthcodeVO.city!=null"> |
| | | and city like concat('%',#{healthcodeVO.city},'%') |
| | | </if> |
| | | <if test="healthcodeVO.district!=null"> |
| | | and district like concat('%',#{healthcodeVO.district},'%') |
| | | </if> |
| | | <if test="healthcodeVO.begTime!=null and healthcodeVO.begTime!='' and healthcodeVO.begTime!='undefined' and healthcodeVO.endTime!='undefined' |
| | | and healthcodeVO.endTime!=null and healthcodeVO.endTime!='' "> |
| | | and date(dtime) between #{healthcodeVO.begTime} and #{healthcodeVO.endTime} |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc!=null and healthcodeVO.timeDesc!='' and healthcodeVO.timeDesc!='undefined' "> |
| | | <if test="healthcodeVO.timeDesc=='0-2'"> |
| | | and hour(dtime)>=0 and hour(dtime) <2 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='2-4'"> |
| | | and hour(dtime)>=2 and hour(dtime) <4 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='4-6'"> |
| | | and hour(dtime)>=4 and hour(dtime) <6 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='6-8'"> |
| | | and hour(dtime)>=6 and hour(dtime) <8 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='8-10'"> |
| | | and hour(dtime)>=8 and hour(dtime) <10 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='10-12'"> |
| | | and hour(dtime)>=10 and hour(dtime) <12 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='12-14'"> |
| | | and hour(dtime)>=12 and hour(dtime) <14 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='14-16'"> |
| | | and hour(dtime)>=14 and hour(dtime) <16 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='16-18'"> |
| | | and hour(dtime)>=16 and hour(dtime) <18 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='18-20'"> |
| | | and hour(dtime)>=18 and hour(dtime) <20 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='20-22'"> |
| | | and hour(dtime)>=20 and hour(dtime) <22 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='22-24'"> |
| | | and hour(dtime)>=22 and hour(dtime) <24 |
| | | </if> |
| | | </if> |
| | | </sql> |
| | | |
| | | |
| | | <insert id="insert"> |
| | | insert into healthcode(<include refid="key"/>) values(<include refid="value"/>) |
| | | </insert> |
| | |
| | | <select id="selectHealthcodeListPage" resultType="org.springblade.jfpt.healthcode.entity.Healthcode"> |
| | | SELECT * FROM healthcode |
| | | where 1=1 |
| | | <if test="healthcodeVO.status==0"> |
| | | and to_days(dtime)=to_days(now()) |
| | | </if> |
| | | <if test="healthcodeVO.status==1"> |
| | | and YEARWEEK(date_format(dtime,'%Y-%m-%d'),1) = YEARWEEK(now(),1) |
| | | </if> |
| | | <if test="healthcodeVO.status==2"> |
| | | and date_format(dtime,'%Y%m') = date_format(now(),'%Y%m') |
| | | </if> |
| | | <if test="healthcodeVO.type!=null"> |
| | | <if test="healthcodeVO.type!=null and healthcodeVO.type!='undefined' "> |
| | | and type=#{healthcodeVO.type} |
| | | </if> |
| | | <if test="healthcodeVO.province!=null"> |
| | | and province like concat('%',#{healthcodeVO.province},'%') |
| | | </if> |
| | | <if test="healthcodeVO.city!=null"> |
| | | and city like concat('%',#{healthcodeVO.city},'%') |
| | | </if> |
| | | <if test="healthcodeVO.district!=null"> |
| | | and district like concat('%',#{healthcodeVO.district},'%') |
| | | </if> |
| | | <if test="healthcodeVO.begTime!=null and healthcodeVO.begTime!='' and healthcodeVO.endTime!=null and healthcodeVO.endTime!='' "> |
| | | and date(dtime) between #{healthcodeVO.begTime} and #{healthcodeVO.endTime} |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc!=null and healthcodeVO.timeDesc!=''"> |
| | | <if test="healthcodeVO.timeDesc=='0-2'"> |
| | | and hour(dtime)>=0 and hour(dtime) <2 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='2-4'"> |
| | | and hour(dtime)>=2 and hour(dtime) <4 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='4-6'"> |
| | | and hour(dtime)>=4 and hour(dtime) <6 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='6-8'"> |
| | | and hour(dtime)>=6 and hour(dtime) <8 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='8-10'"> |
| | | and hour(dtime)>=8 and hour(dtime) <10 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='10-12'"> |
| | | and hour(dtime)>=10 and hour(dtime) <12 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='12-14'"> |
| | | and hour(dtime)>=12 and hour(dtime) <14 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='14-16'"> |
| | | and hour(dtime)>=14 and hour(dtime) <16 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='16-18'"> |
| | | and hour(dtime)>=16 and hour(dtime) <18 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='18-20'"> |
| | | and hour(dtime)>=18 and hour(dtime) <20 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='20-22'"> |
| | | and hour(dtime)>=20 and hour(dtime) <22 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='22-24'"> |
| | | and hour(dtime)>=22 and hour(dtime) <24 |
| | | </if> |
| | | </if> |
| | | <include refid="detailCondition"></include> |
| | | ORDER BY dtime desc |
| | | </select> |
| | | |
| | |
| | | <!--导出健康码数据表格--> |
| | | <select id="exportHealthcode" resultType="org.springblade.common.entity.HealthcodeExcel"> |
| | | SELECT * FROM healthcode |
| | | where 1=1 |
| | | <if test="healthcodeVO.status==0"> |
| | | and to_days(dtime)=to_days(now()) |
| | | </if> |
| | | <if test="healthcodeVO.status==1"> |
| | | and YEARWEEK(date_format(dtime,'%Y-%m-%d'),1) = YEARWEEK(now(),1) |
| | | </if> |
| | | <if test="healthcodeVO.status==2"> |
| | | and date_format(dtime,'%Y%m') = date_format(now(),'%Y%m') |
| | | </if> |
| | | <if test="healthcodeVO.type!=null and healthcodeVO.type!='undefined' "> |
| | | and type=#{healthcodeVO.type} |
| | | </if> |
| | | <if test="healthcodeVO.province!=null"> |
| | | and province like concat('%',#{healthcodeVO.province},'%') |
| | | </if> |
| | | <if test="healthcodeVO.city!=null"> |
| | | and city like concat('%',#{healthcodeVO.city},'%') |
| | | </if> |
| | | <if test="healthcodeVO.district!=null"> |
| | | and district like concat('%',#{healthcodeVO.district},'%') |
| | | </if> |
| | | <if test="healthcodeVO.begTime!=null and healthcodeVO.begTime!='' and healthcodeVO.begTime!='undefined' and healthcodeVO.endTime!='undefined' |
| | | and healthcodeVO.endTime!=null and healthcodeVO.endTime!='' "> |
| | | and date(dtime) between #{healthcodeVO.begTime} and #{healthcodeVO.endTime} |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc!=null and healthcodeVO.timeDesc!='' and healthcodeVO.timeDesc!='undefined' "> |
| | | <if test="healthcodeVO.timeDesc=='0-2'"> |
| | | and hour(dtime)>=0 and hour(dtime) <2 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='2-4'"> |
| | | and hour(dtime)>=2 and hour(dtime) <4 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='4-6'"> |
| | | and hour(dtime)>=4 and hour(dtime) <6 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='6-8'"> |
| | | and hour(dtime)>=6 and hour(dtime) <8 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='8-10'"> |
| | | and hour(dtime)>=8 and hour(dtime) <10 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='10-12'"> |
| | | and hour(dtime)>=10 and hour(dtime) <12 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='12-14'"> |
| | | and hour(dtime)>=12 and hour(dtime) <14 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='14-16'"> |
| | | and hour(dtime)>=14 and hour(dtime) <16 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='16-18'"> |
| | | and hour(dtime)>=16 and hour(dtime) <18 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='18-20'"> |
| | | and hour(dtime)>=18 and hour(dtime) <20 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='20-22'"> |
| | | and hour(dtime)>=20 and hour(dtime) <22 |
| | | </if> |
| | | <if test="healthcodeVO.timeDesc=='22-24'"> |
| | | and hour(dtime)>=22 and hour(dtime) <24 |
| | | </if> |
| | | </if> |
| | | where 1=1 |
| | | <include refid="detailCondition"></include> |
| | | ORDER BY dtime desc |
| | | </select> |
| | | |
| | | <!--导出健康码数据报表--> |
| | | <select id="getHealthcodePie" resultType="org.springblade.common.entity.ReportReturnData"> |
| | | select if(1=1,'绿色健康码',0) type,ifnull(count(*),0) count from healthcode where type=1 |
| | | <include refid="detailCondition"></include> |
| | | union all |
| | | select if(1=1,'黄色健康码',0) type,ifnull(count(*),0) count from healthcode where type=2 |
| | | <include refid="detailCondition"></include> |
| | | union all |
| | | select if(1=1,'红色健康码',0) type,ifnull(count(*),0) count from healthcode where type=3 |
| | | <include refid="detailCondition"></include> |
| | | </select> |
| | | </mapper> |
| | |
| | | * @param healthcodeVO 查询条件 |
| | | */ |
| | | List<HealthcodeExcel> exportHealthcode(HealthcodeVO healthcodeVO); |
| | | |
| | | /** |
| | | * 获取健康码图标数据 |
| | | * @param healthcodeVO 查询条件 |
| | | * @return |
| | | */ |
| | | List<HealthcodeExcel> getHealthcodePie(HealthcodeVO healthcodeVO); |
| | | } |
| | |
| | | public List<HealthcodeExcel> exportHealthcode(HealthcodeVO healthcodeVO) { |
| | | return baseMapper.exportHealthcode(healthcodeVO); |
| | | } |
| | | |
| | | /** |
| | | * 获取健康码图标数据 |
| | | * @param healthcodeVO 查询条件 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<HealthcodeExcel> getHealthcodePie(HealthcodeVO healthcodeVO) { |
| | | return baseMapper.getHealthcodePie(healthcodeVO); |
| | | } |
| | | } |
| New file |
| | |
| | | package org.springblade.jfpt.pie; |
| | | |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.alibaba.excel.annotation.write.style.ColumnWidth; |
| | | import com.alibaba.excel.annotation.write.style.ContentRowHeight; |
| | | import com.alibaba.excel.annotation.write.style.HeadRowHeight; |
| | | import lombok.Data; |
| | | import java.io.InputStream; |
| | | |
| | | @Data |
| | | @ContentRowHeight(254) |
| | | @HeadRowHeight(20) |
| | | //@ColumnWidth(100 / 8) |
| | | public class ImageData { |
| | | |
| | | @ColumnWidth(50) |
| | | @ExcelProperty("统计图") |
| | | private InputStream inputStream; |
| | | } |
| New file |
| | |
| | | package org.springblade.jfpt.pie; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.ExcelWriter; |
| | | import com.alibaba.excel.write.metadata.WriteSheet; |
| | | import lombok.AllArgsConstructor; |
| | | import org.jfree.chart.ChartFactory; |
| | | import org.jfree.chart.ChartUtilities; |
| | | import org.jfree.chart.JFreeChart; |
| | | import org.jfree.chart.labels.StandardPieSectionLabelGenerator; |
| | | import org.jfree.chart.plot.PiePlot; |
| | | import org.jfree.data.general.DefaultPieDataset; |
| | | import org.springblade.common.entity.AnimalHeatExcel; |
| | | import org.springblade.common.entity.ReportReturnData; |
| | | import org.springblade.jfpt.animalheat.service.AnimalHeatService; |
| | | import org.springblade.jfpt.animalheat.service.impl.AnimalHeatServiceImpl; |
| | | import org.springblade.jfpt.animalheat.vo.AnimalHeatVo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.awt.*; |
| | | import java.io.*; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | | public class JFreeChartUtil { |
| | | |
| | | |
| | | |
| | | public JFreeChartUtil() { |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | DefaultPieDataset pds = new DefaultPieDataset(); |
| | | |
| | | pds.setValue("00点", 100); |
| | | pds.setValue("04点", 200); |
| | | pds.setValue("08点", 300); |
| | | String filePath = "d:/pie.jpg"; |
| | | createPieChart(pds); |
| | | |
| | | } |
| | | |
| | | public static void createPieChart(DefaultPieDataset pds) { |
| | | |
| | | // AnimalHeatService animalHeatService = new AnimalHeatServiceImpl(); |
| | | // |
| | | // AnimalHeatVo animalHeatVo = new AnimalHeatVo(); |
| | | // animalHeatVo.setStatus(1); |
| | | // animalHeatVo.setBegTime("2021-04-01 00:00:00"); |
| | | // animalHeatVo.setEndTime("2021-04-01 00:00:00"); |
| | | // |
| | | // List<ReportReturnData> heatExcels = animalHeatService.getAnimalHeatPie(animalHeatVo); |
| | | |
| | | try { |
| | | // 分别是:显示图表的标题、需要提供对应图表的DateSet对象、是否显示图例、是否生成贴士以及是否生成URL链接 |
| | | JFreeChart chart = ChartFactory.createPieChart("体温数据分布图", pds, false, false, true); |
| | | // 如果不使用Font,中文将显示不出来 |
| | | Font font = new Font("宋体", Font.BOLD, 24); |
| | | // 设置图片标题的字体 |
| | | chart.getTitle().setFont(font); |
| | | // 得到图块,准备设置标签的字体 |
| | | PiePlot plot = (PiePlot) chart.getPlot(); |
| | | // 设置标签字体 |
| | | plot.setLabelFont(font); |
| | | plot.setStartAngle(new Float(3.14f / 2f)); |
| | | // 设置plot的前景色透明度 |
| | | plot.setForegroundAlpha(0.7f); |
| | | // 设置plot的背景色透明度 |
| | | plot.setBackgroundAlpha(0.0f); |
| | | // 设置标签生成器(默认{0}) |
| | | // {0}:key {1}:value {2}:百分比 {3}:sum |
| | | plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}({1}占{2})")); |
| | | ByteArrayOutputStream bos = new ByteArrayOutputStream(); |
| | | |
| | | ArrayList<ImageData> list = new ArrayList<>(); |
| | | ImageData imageData = new ImageData(); |
| | | try { |
| | | // 将图表写入到ByteArrayOutputStream流中 |
| | | ChartUtilities.writeChartAsJPEG(bos, chart, 800, 700); |
| | | System.out.println("bos = " + bos); |
| | | InputStream inputStream = new ByteArrayInputStream(bos.toByteArray()); |
| | | String fileName = "imageWrite" + System.currentTimeMillis() + ".xlsx"; |
| | | imageData.setInputStream(inputStream); |
| | | list.add(imageData); |
| | | //写入 |
| | | ExcelWriter excelWriter = EasyExcel.write(fileName).build(); |
| | | |
| | | WriteSheet writeSheet = EasyExcel.writerSheet(0, "模板0").head(ImageData.class).build(); |
| | | excelWriter.write(list, writeSheet); |
| | | |
| | | // WriteSheet writeSheet0 = EasyExcel.writerSheet(1, "模板1").head(ReportReturnData.class).build(); |
| | | // excelWriter.write(heatExcels, writeSheet0); |
| | | |
| | | excelWriter.finish(); |
| | | |
| | | |
| | | //EasyExcel.write(fileName, ImageData.class).sheet().doWrite(list); |
| | | //EasyExcel.write(fileName, ImageData.class).sheet().doWrite(list); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // 将内存中的图片写到本地硬盘 |
| | | //ChartUtilities.saveChartAsJPEG(new File(filePath), chart, 600, 300); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | }finally { |
| | | } |
| | | } |
| | | } |