Commit 5fd83797 authored by taabe's avatar taabe

增加设备点位数据导出功能;修改FileHelper中downLoadExcel中bug(注释掉response.reset())

parent e761f0b7
...@@ -5,6 +5,7 @@ import com.yeejoin.amos.fas.business.param.FireEquipmentParam; ...@@ -5,6 +5,7 @@ import com.yeejoin.amos.fas.business.param.FireEquipmentParam;
import com.yeejoin.amos.fas.business.param.FireEquipmentPointParam; import com.yeejoin.amos.fas.business.param.FireEquipmentPointParam;
import com.yeejoin.amos.fas.business.service.intfc.IExcelService; import com.yeejoin.amos.fas.business.service.intfc.IExcelService;
import com.yeejoin.amos.fas.business.util.FileHelper; import com.yeejoin.amos.fas.business.util.FileHelper;
import com.yeejoin.amos.fas.core.util.FileUtil;
import com.yeejoin.amos.op.core.common.response.CommonResponse; import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.util.CommonResponseUtil; import com.yeejoin.amos.op.core.util.CommonResponseUtil;
import com.yeejoin.amos.security.authorization.Authorization; import com.yeejoin.amos.security.authorization.Authorization;
...@@ -14,15 +15,12 @@ import io.swagger.annotations.ApiParam; ...@@ -14,15 +15,12 @@ import io.swagger.annotations.ApiParam;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
@RestController @RestController
...@@ -72,6 +70,33 @@ public class ExcelController extends BaseController { ...@@ -72,6 +70,33 @@ public class ExcelController extends BaseController {
} }
@ApiOperation(value = "导出数据", notes = "导出数据") @ApiOperation(value = "导出数据", notes = "导出数据")
@PostMapping(value = "/export2")
@Authorization(ingore = true)
public void export2(HttpServletResponse response,
@ApiParam(value = "data:导出数据;model:导出模板", required = true) @RequestParam String exportType,
@ApiParam(value = "point:监测点;equipment:设备", required = true) @RequestParam String modelName,
@ApiParam(value = "查询条件") @RequestBody(required = false) Map<String, Object> paramsMap) {
String fileName = UUID.randomUUID().toString() + ".xls";
String title = "监测点";
Class cls = null;
if ("point".equals(modelName)) {
cls = FireEquipmentPointParam.class;
} else if ("equipment".equals(modelName)) {
cls = FireEquipmentParam.class;
}
if (cls != null) {
List<?> list = Lists.newArrayList();
// if ("model".equals(exportType)) {
// FileHelper.exportExcel(list, title, title, cls, fileName, response);
// }
if ("data".equals(exportType)) {
list = iExcelService.exportPointData(paramsMap);
}
FileHelper.exportExcel(list, title, title, cls, fileName, response);
}
}
@ApiOperation(value = "导出数据", notes = "导出数据")
@PostMapping(value = "/export") @PostMapping(value = "/export")
@Authorization(ingore = true) @Authorization(ingore = true)
public void export(HttpServletResponse response, public void export(HttpServletResponse response,
......
...@@ -30,6 +30,8 @@ public class FireEquipmentPointEntity extends FireEquipmentPointExtend { ...@@ -30,6 +30,8 @@ public class FireEquipmentPointEntity extends FireEquipmentPointExtend {
private Long alarmType; private Long alarmType;
private String fireEquipmentCode;
public Long getId() { public Long getId() {
return id; return id;
} }
...@@ -125,4 +127,12 @@ public class FireEquipmentPointEntity extends FireEquipmentPointExtend { ...@@ -125,4 +127,12 @@ public class FireEquipmentPointEntity extends FireEquipmentPointExtend {
public void setAlarmType(Long alarmType) { public void setAlarmType(Long alarmType) {
this.alarmType = alarmType; this.alarmType = alarmType;
} }
public String getFireEquipmentCode() {
return fireEquipmentCode;
}
public void setFireEquipmentCode(String fireEquipmentCode) {
this.fireEquipmentCode = fireEquipmentCode;
}
} }
...@@ -6,25 +6,30 @@ public class FireEquipmentPointParam { ...@@ -6,25 +6,30 @@ public class FireEquipmentPointParam {
private Long id; private Long id;
@Excel(name = "名称", orderNum = "1") @Excel(name = "名称", orderNum = "1", width = 50)
private String name; private String name;
@Excel(name = "编号", orderNum = "2", width = 12)
@Excel(name = "编号", orderNum = "2")
private String code; private String code;
@Excel(name = "消防装备编号", orderNum = "3") @Excel(name = "消防装备编号", orderNum = "3", width = 15)
private String fireEquipmentCode; private String fireEquipmentCode;
@Excel(name = "消防装备名称", orderNum = "4", width = 50)
private String fireEquipmentName;
private Long fireEquipmentId; private Long fireEquipmentId;
@Excel(name = "类型", replace = {"模拟量_ANALOGUE", "开关量_SWITCH"}, orderNum = "4") @Excel(name = "类型", replace = {"模拟量_ANALOGUE", "开关量_SWITCH"}, orderNum = "5")
private String type; private String type;
@Excel(name = "单位", orderNum = "5") @Excel(name = "值", replace = {"是_true", "否_false"}, orderNum = "6", width = 12)
private String value;
@Excel(name = "单位", orderNum = "7", width = 12)
private String unit; private String unit;
@Excel(name = "告警类型", replace = {"火灾告警_1", "电源开关_2", "换流变_6", "液位_3", "流量_4", "容量_5"}, orderNum = "6") @Excel(name = "告警类型", replace = {"火灾告警_1", "电源开关_2", "换流变_6", "液位_3", "流量_4", "容量_5"}, orderNum = "8")
private Long alarmType; private Long alarmType;
public Long getId() { public Long getId() {
...@@ -90,4 +95,20 @@ public class FireEquipmentPointParam { ...@@ -90,4 +95,20 @@ public class FireEquipmentPointParam {
public void setFireEquipmentId(Long fireEquipmentId) { public void setFireEquipmentId(Long fireEquipmentId) {
this.fireEquipmentId = fireEquipmentId; this.fireEquipmentId = fireEquipmentId;
} }
public String getFireEquipmentName() {
return fireEquipmentName;
}
public void setFireEquipmentName(String fireEquipmentName) {
this.fireEquipmentName = fireEquipmentName;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
} }
...@@ -10,11 +10,16 @@ import com.yeejoin.amos.fas.business.entity.mybatis.FireEquipmentPointEntity; ...@@ -10,11 +10,16 @@ import com.yeejoin.amos.fas.business.entity.mybatis.FireEquipmentPointEntity;
import com.yeejoin.amos.fas.business.param.FireEquipmentParam; import com.yeejoin.amos.fas.business.param.FireEquipmentParam;
import com.yeejoin.amos.fas.business.param.FireEquipmentPointParam; import com.yeejoin.amos.fas.business.param.FireEquipmentPointParam;
import com.yeejoin.amos.fas.business.service.intfc.IExcelService; import com.yeejoin.amos.fas.business.service.intfc.IExcelService;
import com.yeejoin.amos.fas.business.service.intfc.IFireEquipPontService;
import com.yeejoin.amos.op.core.common.response.CommonResponse;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
...@@ -28,6 +33,9 @@ public class ExcelServiceImpl implements IExcelService { ...@@ -28,6 +33,9 @@ public class ExcelServiceImpl implements IExcelService {
@Autowired @Autowired
private FireEquipPointMapper fireEquipPointMapper; private FireEquipPointMapper fireEquipPointMapper;
@Autowired
private IFireEquipPontService fireEquipPontService;
@Transactional @Transactional
@Override @Override
public void importFireEquipment(List<FireEquipmentParam> list) { public void importFireEquipment(List<FireEquipmentParam> list) {
...@@ -90,4 +98,17 @@ public class ExcelServiceImpl implements IExcelService { ...@@ -90,4 +98,17 @@ public class ExcelServiceImpl implements IExcelService {
fireEquipPointMapper.updateBatch(updateList); fireEquipPointMapper.updateBatch(updateList);
} }
} }
@Override
public List<?> exportPointData(Map<String, Object> paramsMap) {
CommonResponse result = fireEquipPontService.queryByMap(paramsMap);
List<FireEquipmentPointEntity> fireEquipmentPoints = ((PageImpl) result.getDataList()).getContent();
List<FireEquipmentPointParam> pointExcelList = new ArrayList<>();
for (FireEquipmentPointEntity point : fireEquipmentPoints) {
FireEquipmentPointParam pointParam = new FireEquipmentPointParam();
BeanUtils.copyProperties(point, pointParam);
pointExcelList.add(pointParam);
}
return pointExcelList;
}
} }
...@@ -4,6 +4,7 @@ import com.yeejoin.amos.fas.business.param.FireEquipmentParam; ...@@ -4,6 +4,7 @@ import com.yeejoin.amos.fas.business.param.FireEquipmentParam;
import com.yeejoin.amos.fas.business.param.FireEquipmentPointParam; import com.yeejoin.amos.fas.business.param.FireEquipmentPointParam;
import java.util.List; import java.util.List;
import java.util.Map;
public interface IExcelService { public interface IExcelService {
...@@ -11,4 +12,5 @@ public interface IExcelService { ...@@ -11,4 +12,5 @@ public interface IExcelService {
void importFireEquipmentPoint(List<FireEquipmentPointParam> list); void importFireEquipmentPoint(List<FireEquipmentPointParam> list);
List<?> exportPointData(Map<String, Object> paramsMap);
} }
...@@ -892,7 +892,7 @@ public class FileHelper { ...@@ -892,7 +892,7 @@ public class FileHelper {
private static void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) { private static void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) {
try { try {
String name = new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1); String name = new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);
response.reset(); // response.reset();
response.setHeader("content-Type", "application/vnd.ms-excel"); response.setHeader("content-Type", "application/vnd.ms-excel");
response.setHeader("Content-Disposition", response.setHeader("Content-Disposition",
"attachment;filename=" + name); "attachment;filename=" + name);
......
...@@ -132,7 +132,8 @@ ...@@ -132,7 +132,8 @@
a.unit, a.unit,
a.org_code as orgCode, a.org_code as orgCode,
a.alarm_type as alarmType, a.alarm_type as alarmType,
b.name as fireEquipmentName b.name as fireEquipmentName,
b.code as fireEquipmentCode
from from
f_fire_equipment_point as a f_fire_equipment_point as a
left join left join
...@@ -149,7 +150,7 @@ ...@@ -149,7 +150,7 @@
</if> </if>
</where> </where>
order by a.create_date desc order by a.create_date desc
<if test="pageSize!=null and pageNumber!=null"> <if test="pageSize!=null and pageSize!=-1 and pageNumber!=null">
limit #{pageNumber},#{pageSize} limit #{pageNumber},#{pageSize}
</if> </if>
</select> </select>
......
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