|
@@ -0,0 +1,581 @@
|
|
|
+package com.jiayue.ipfcst.console.controller;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import com.jiayue.ipfcst.aop.SaveValidate;
|
|
|
+import com.jiayue.ipfcst.common.core.util.JsonBeanUtil;
|
|
|
+import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
|
|
|
+import com.jiayue.ipfcst.common.data.constant.enums.ElectricFieldStatrsEnum;
|
|
|
+import com.jiayue.ipfcst.common.data.constant.enums.ElectricFieldTypeEnum;
|
|
|
+import com.jiayue.ipfcst.common.data.constant.enums.ProvinceEnum;
|
|
|
+import com.jiayue.ipfcst.common.data.entity.ElectricField;
|
|
|
+import com.jiayue.ipfcst.common.data.entity.OverhaulPlan;
|
|
|
+import com.jiayue.ipfcst.common.data.entity.Quartz;
|
|
|
+import com.jiayue.ipfcst.common.data.entity.SysParameter;
|
|
|
+
|
|
|
+import com.jiayue.ipfcst.console.service.*;
|
|
|
+
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.BufferedOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 场站信息restful接口
|
|
|
+ *
|
|
|
+ * @author tl
|
|
|
+ * @version 3.0
|
|
|
+ * @since 2020/6/28 10:12
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/electricField")
|
|
|
+@Slf4j
|
|
|
+public class ElectricFieldController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ElectricFieldService electricFieldService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ SysParameterService sysParameterService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ OverHaulPlanService overHaulPlanService;
|
|
|
+
|
|
|
+ /* @Autowired
|
|
|
+ InverterInfoService inverterInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ WeatherStationInfoService weatherStationInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ WindTowerInfoService windTowerInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ WindTurbineInfoService windTurbineInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ PvModuleModelService pvModuleModelService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ UploadObjectService uploadObjectService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ UploadFileChannelService uploadFileChannelService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ UploadFileCodeService uploadFileCodeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ UploadURLService uploadURLService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ TunnelInfoService tunnelInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ EquipmentAttributeService equipmentAttributeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ProtocolSenderDataPointService protocolSenderDataPointService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ProtocolGatherDataPointService protocolGatherDataPointService;*/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增场站信息
|
|
|
+ *
|
|
|
+ * @param electricField 场站实体参数
|
|
|
+ * @return 执行结果
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/")
|
|
|
+ @SaveValidate
|
|
|
+ public ResponseVO saveElectricField(@RequestBody ElectricField electricField) {
|
|
|
+ try {
|
|
|
+ electricFieldService.update(electricField);
|
|
|
+ return ResponseVO.success();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error(" 保存场站信息异常");
|
|
|
+ return ResponseVO.fail();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新场站信息
|
|
|
+ *
|
|
|
+ * @param electricField 场站实体参数
|
|
|
+ * @return 执行结果
|
|
|
+ */
|
|
|
+ @PutMapping(value = "/")
|
|
|
+ @SaveValidate
|
|
|
+ public ResponseVO updateElectricField(@RequestBody ElectricField electricField) {
|
|
|
+ try {
|
|
|
+ this.electricFieldService.update(electricField);
|
|
|
+ return ResponseVO.success();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error(" 更新场站信息异常");
|
|
|
+ return ResponseVO.fail();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取场站信息
|
|
|
+ *
|
|
|
+ * @return 所有场站信息
|
|
|
+ */
|
|
|
+
|
|
|
+ @GetMapping(value = "/")
|
|
|
+ public ResponseVO getElectricField() {
|
|
|
+ try {
|
|
|
+ List<ElectricField> electricFieldList = this.electricFieldService.getAll();
|
|
|
+ return ResponseVO.success(electricFieldList);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error(" 获取场站信息异常");
|
|
|
+ return ResponseVO.success(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @DeleteMapping(value = "/{stationCode}")
|
|
|
+ @SaveValidate
|
|
|
+ public ResponseVO deleteElectricField(@PathVariable String stationCode) {
|
|
|
+ try {
|
|
|
+ electricFieldService.delete(stationCode);
|
|
|
+ return ResponseVO.success();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error(" 删除场站信息异常");
|
|
|
+ return ResponseVO.fail();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 功能描述: <br>
|
|
|
+ * 〈返回上报类型〉
|
|
|
+ *
|
|
|
+ * @param: []
|
|
|
+ * @Return: com.jiayue.ipfcst.console.dto.ResponseBean
|
|
|
+ * @Author: YH
|
|
|
+ * @Date: 2020/3/3 14:08
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/getProvince")
|
|
|
+ public ResponseVO getProvince() {
|
|
|
+ List<Map<String, Object>> provinceType = new ArrayList<>();
|
|
|
+ Map<String, Object> map;
|
|
|
+ try {
|
|
|
+ for (ProvinceEnum e : ProvinceEnum.values()) {
|
|
|
+ map = new HashMap<>();
|
|
|
+ map.put("label", e.getMessage());
|
|
|
+ map.put("key", e.name());
|
|
|
+ map.put("value", e.name());
|
|
|
+ provinceType.add(map);
|
|
|
+ }
|
|
|
+ return ResponseVO.success(provinceType);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error(" 获取场站上报类型异常");
|
|
|
+ return ResponseVO.fail(provinceType);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 功能描述: <br>
|
|
|
+ * 〈返回场站类型〉
|
|
|
+ *
|
|
|
+ * @param: []
|
|
|
+ * @Return: com.jiayue.ipfcst.console.dto.ResponseBean
|
|
|
+ * @Author: YH
|
|
|
+ * @Date: 2020/3/3 14:08
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/getElType")
|
|
|
+ public ResponseVO getElType() {
|
|
|
+ List<Map<String, Object>> elType = new ArrayList<>();
|
|
|
+ Map<String, Object> map;
|
|
|
+ try {
|
|
|
+ for (ElectricFieldTypeEnum e : ElectricFieldTypeEnum.values()) {
|
|
|
+ map = new HashMap<>();
|
|
|
+ map.put("label", e.getMessage());
|
|
|
+ map.put("key", e.name());
|
|
|
+ map.put("value", e.name());
|
|
|
+ elType.add(map);
|
|
|
+ }
|
|
|
+ return ResponseVO.success(elType);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error(" 获取场站类型异常");
|
|
|
+ return ResponseVO.fail(elType);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping(value = "/getElectricFieldStatrsEnum")
|
|
|
+ public ResponseVO getElectricFieldStatrsEnum() {
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
+ Map<String, Object> map;
|
|
|
+ try {
|
|
|
+ for (ElectricFieldStatrsEnum e : ElectricFieldStatrsEnum.values()) {
|
|
|
+ map = new HashMap<>();
|
|
|
+ map.put("label", e.getMessage());
|
|
|
+ map.put("key", e.name());
|
|
|
+ map.put("value", e.name());
|
|
|
+ list.add(map);
|
|
|
+ }
|
|
|
+ return ResponseVO.success(list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error(" 获取场站状态类型异常");
|
|
|
+ return ResponseVO.fail(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /*@PostMapping(value = "/dataDownload")
|
|
|
+ public void dataDownload(HttpServletRequest request,
|
|
|
+ HttpServletResponse response) {
|
|
|
+ BufferedOutputStream bos = null;
|
|
|
+ try {
|
|
|
+ response.setCharacterEncoding("UTF-8");
|
|
|
+ StringBuilder templateContent = new StringBuilder();
|
|
|
+ ElectricField electricField = electricFieldService.getElectricField();
|
|
|
+ // 添加第一行
|
|
|
+ String header = electricField.getStationCode();
|
|
|
+ templateContent.append(header + "\r\n");
|
|
|
+
|
|
|
+ List<String> vals = new ArrayList<>();
|
|
|
+ String val;
|
|
|
+ String type = "All";
|
|
|
+ List<ElectricField> electricFields = new ArrayList<>();
|
|
|
+ electricFields.add(electricField);
|
|
|
+ val = "ElectricField:::" + JsonBeanUtil.beanToJson(electricFields);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+
|
|
|
+ if (type.equals("All")) {
|
|
|
+ List<PvModuleModel> beans = pvModuleModelService.getAll();
|
|
|
+ if (null != beans && beans.size() > 0) {
|
|
|
+ for (PvModuleModel bean : beans) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "PvModuleModel:::" + JsonBeanUtil.beanToJson(beans);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (type.equals("All")) {
|
|
|
+ List<OverhaulPlan> beans = overHaulPlanService.getAll();
|
|
|
+ if (null != beans && beans.size() > 0) {
|
|
|
+ for (OverhaulPlan bean : beans) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "OverhaulPlan:::" + JsonBeanUtil.beanToJson(beans);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (type.equals("All")) {
|
|
|
+ List<InverterInfo> beans = inverterInfoService.getAll();
|
|
|
+ if (null != beans && beans.size() > 0) {
|
|
|
+ for (InverterInfo bean : beans) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "InverterInfo:::" + JsonBeanUtil.beanToJson(beans);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (type.equals("All")) {
|
|
|
+ List<WeatherStationInfo> beans = weatherStationInfoService.getAll();
|
|
|
+ if (null != beans && beans.size() > 0) {
|
|
|
+ for (WeatherStationInfo bean : beans) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "WeatherStationInfo:::" + JsonBeanUtil.beanToJson(beans);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (type.equals("All")) {
|
|
|
+ List<WindTowerInfo> beans = windTowerInfoService.getAll();
|
|
|
+ if (null != beans && beans.size() > 0) {
|
|
|
+ for (WindTowerInfo bean : beans) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "WindTowerInfo:::" + JsonBeanUtil.beanToJson(beans);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (type.equals("All")) {
|
|
|
+ List<WindTurbineInfo> beans = windTurbineInfoService.getAll();
|
|
|
+ if (null != beans && beans.size() > 0) {
|
|
|
+ for (WindTurbineInfo bean : beans) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "WindTurbineInfo:::" + JsonBeanUtil.beanToJson(beans);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (type.equals("All")) {
|
|
|
+ List<SysParameter> beans = sysParameterService.getAll();
|
|
|
+ if (null != beans && beans.size() > 0) {
|
|
|
+ for (SysParameter bean : beans) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "SysParameter:::" + JsonBeanUtil.beanToJson(beans);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (type.equals("All")) {
|
|
|
+ //文件上报部分
|
|
|
+ List<UploadObject> beans = uploadObjectService.get();
|
|
|
+ if (null != beans && beans.size() > 0) {
|
|
|
+ for (UploadObject bean : beans) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "UploadObject:::" + JsonBeanUtil.beanToJson(beans);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<UploadFileChannel> uploadFileChannels = uploadFileChannelService.get();
|
|
|
+ if (null != uploadFileChannels && uploadFileChannels.size() > 0) {
|
|
|
+ for (UploadFileChannel bean : uploadFileChannels) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "UploadFileChannel:::" + JsonBeanUtil.beanToJson(uploadFileChannels);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<UploadFileCode> uploadFileCodes = uploadFileCodeService.get();
|
|
|
+ if (null != uploadFileCodes && uploadFileCodes.size() > 0) {
|
|
|
+ for (UploadFileCode bean : uploadFileCodes) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "UploadFileCode:::" + JsonBeanUtil.beanToJson(uploadFileCodes);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<UploadURL> uploadURLS = uploadURLService.findAll();
|
|
|
+ if (null != uploadURLS && uploadURLS.size() > 0) {
|
|
|
+ for (UploadURL bean : uploadURLS) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "UploadURL:::" + JsonBeanUtil.beanToJson(uploadURLS);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //数据接入部分
|
|
|
+ List<EquipmentAttribute> equipmentAttributes = equipmentAttributeService.getAll();
|
|
|
+ if (null != equipmentAttributes && equipmentAttributes.size() > 0) {
|
|
|
+ for (EquipmentAttribute bean : equipmentAttributes) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "EquipmentAttribute:::" + JsonBeanUtil.beanToJson(equipmentAttributes);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<FileParseTunnelInfo> fileParseTunnelInfos = tunnelInfoService.getAllFileParseTunnel();
|
|
|
+ if (null != fileParseTunnelInfos && fileParseTunnelInfos.size() > 0) {
|
|
|
+ for (FileParseTunnelInfo bean : fileParseTunnelInfos) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "FileParseTunnelInfo:::" + JsonBeanUtil.beanToJson(fileParseTunnelInfos);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Gather104TcpTunnelInfo> gather104TcpTunnelInfos = tunnelInfoService.getAllGather104TcpTunnel();
|
|
|
+ if (null != gather104TcpTunnelInfos && gather104TcpTunnelInfos.size() > 0) {
|
|
|
+ for (Gather104TcpTunnelInfo bean : gather104TcpTunnelInfos) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "Gather104TcpTunnelInfo:::" + JsonBeanUtil.beanToJson(gather104TcpTunnelInfos);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<GatherCdtRtuTunnelInfo> gatherCdtRtuTunnelInfos = tunnelInfoService.getAllGatherCdtRtuTunnel();
|
|
|
+ if (null != gatherCdtRtuTunnelInfos && gatherCdtRtuTunnelInfos.size() > 0) {
|
|
|
+ for (GatherCdtRtuTunnelInfo bean : gatherCdtRtuTunnelInfos) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "GatherCdtRtuTunnelInfo:::" + JsonBeanUtil.beanToJson(gatherCdtRtuTunnelInfos);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<GatherModbusRtuTunnelInfo> gatherModbusRtuTunnelInfos =
|
|
|
+ tunnelInfoService.getAllGatherModbusRtuTunnel();
|
|
|
+ if (null != gatherModbusRtuTunnelInfos && gatherModbusRtuTunnelInfos.size() > 0) {
|
|
|
+ for (GatherModbusRtuTunnelInfo bean : gatherModbusRtuTunnelInfos) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "GatherModbusRtuTunnelInfo:::" + JsonBeanUtil.beanToJson(gatherModbusRtuTunnelInfos);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<GatherModbusTcpTunnelInfo> gatherModbusTcpTunnelInfos =
|
|
|
+ tunnelInfoService.getAllGatherModbusTcpTunnel();
|
|
|
+ if (null != gatherModbusTcpTunnelInfos && gatherModbusTcpTunnelInfos.size() > 0) {
|
|
|
+ for (GatherModbusTcpTunnelInfo bean : gatherModbusTcpTunnelInfos) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "GatherModbusTcpTunnelInfo:::" + JsonBeanUtil.beanToJson(gatherModbusTcpTunnelInfos);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Sender104TcpTunnelInfo> sender104TcpTunnelInfos = tunnelInfoService.getAllSender104TcpTunnel();
|
|
|
+ if (null != sender104TcpTunnelInfos && sender104TcpTunnelInfos.size() > 0) {
|
|
|
+ for (Sender104TcpTunnelInfo bean : sender104TcpTunnelInfos) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "Sender104TcpTunnelInfo:::" + JsonBeanUtil.beanToJson(sender104TcpTunnelInfos);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SenderCdtRtuTunnelInfo> senderCdtRtuTunnelInfos = tunnelInfoService.getAllSenderCdtRtuTunnel();
|
|
|
+ if (null != senderCdtRtuTunnelInfos && senderCdtRtuTunnelInfos.size() > 0) {
|
|
|
+ for (SenderCdtRtuTunnelInfo bean : senderCdtRtuTunnelInfos) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "SenderCdtRtuTunnelInfo:::" + JsonBeanUtil.beanToJson(senderCdtRtuTunnelInfos);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SenderModbusRtuTunnelInfo> senderModbusRtuTunnelInfos =
|
|
|
+ tunnelInfoService.getAllSenderModbusRtuTunnel();
|
|
|
+ if (null != senderModbusRtuTunnelInfos && senderModbusRtuTunnelInfos.size() > 0) {
|
|
|
+ for (SenderModbusRtuTunnelInfo bean : senderModbusRtuTunnelInfos) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "SenderModbusRtuTunnelInfo:::" + JsonBeanUtil.beanToJson(senderModbusRtuTunnelInfos);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SenderModbusTcpTunnelInfo> senderModbusTcpTunnelInfos =
|
|
|
+ tunnelInfoService.getAllSenderModbusTcpTunnel();
|
|
|
+ if (null != senderModbusTcpTunnelInfos && senderModbusTcpTunnelInfos.size() > 0) {
|
|
|
+ for (SenderModbusTcpTunnelInfo bean : senderModbusTcpTunnelInfos) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "SenderModbusTcpTunnelInfo:::" + JsonBeanUtil.beanToJson(senderModbusTcpTunnelInfos);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ProtocolSenderDataPoint> protocolSenderDataPoints = protocolSenderDataPointService.get();
|
|
|
+ if (null != protocolSenderDataPoints && protocolSenderDataPoints.size() > 0) {
|
|
|
+ for (ProtocolSenderDataPoint bean : protocolSenderDataPoints) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "ProtocolSenderDataPoint:::" + JsonBeanUtil.beanToJson(protocolSenderDataPoints);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ProtocolGatherDataPoint> protocolGatherDataPoints = protocolGatherDataPointService.getAll();
|
|
|
+ if (null != protocolGatherDataPoints && protocolGatherDataPoints.size() > 0) {
|
|
|
+ for (ProtocolGatherDataPoint bean : protocolGatherDataPoints) {
|
|
|
+ bean.setStationCode(header);
|
|
|
+ }
|
|
|
+ val = "ProtocolGatherDataPoint:::" + JsonBeanUtil.beanToJson(protocolGatherDataPoints);
|
|
|
+ templateContent.append(val + "\r\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ byte[] templateContentBytes = templateContent.toString().getBytes("UTF-8");
|
|
|
+ long fileLength = templateContentBytes.length + 3;
|
|
|
+ response.setContentType("application/x-msdownload;charset=UTF-8");
|
|
|
+
|
|
|
+
|
|
|
+ response.setHeader("Content-disposition",
|
|
|
+ "attachment; filename=" + URLEncoder.encode(electricField.getStationCode() + "-" + DateUtil.today() + ".rb", "UTF-8"));
|
|
|
+ response.setHeader("Content-Length", String.valueOf(fileLength));
|
|
|
+ bos = new BufferedOutputStream(response.getOutputStream());
|
|
|
+ bos.write(new byte[]{(byte) 0xEF, (byte) 0xBB, (byte) 0xBF});
|
|
|
+ bos.write(templateContentBytes);
|
|
|
+ response.flushBuffer();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("系统错误:" + e.getMessage(), e);
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ } finally {
|
|
|
+ if (bos != null)
|
|
|
+ try {
|
|
|
+ bos.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("系统错误:" + e.getMessage(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+
|
|
|
+ //导出所有场站
|
|
|
+ @RequestMapping(value = "/export")
|
|
|
+ public void export(HttpServletResponse response) {
|
|
|
+ BufferedOutputStream bos = null;
|
|
|
+ try {
|
|
|
+ StringBuilder templateContent = new StringBuilder();
|
|
|
+ response.setCharacterEncoding("UTF-8");
|
|
|
+ List<ElectricField> electricFieldList = electricFieldService.getAll();
|
|
|
+ String header = "\"场站编号\"" + "," + "\"场站状态\"" + "," + "\"场站名称\"" + "," + "\"场站标识\"" + "," + "\"别名\"" + "," + "\"装机容量\"" + "," + "\"并网设备数\"" + "," + "\"场站经度\"" + "," + "\"场站纬度\"" + "," + "\"场站类型\"" + "," + "\"上报省调\"" + "," + "\"入库时间\"" + "," + "\"场站海拔\"" + "," + "\"场站所属公司\"" + "," + "\"场站位置\"" + "," + "\"场站面积\"" + "\r\n";
|
|
|
+
|
|
|
+ StringBuilder content = new StringBuilder();
|
|
|
+ for(ElectricField electricField:electricFieldList){
|
|
|
+ content.append(electricField.getStationCode() + ",");
|
|
|
+ content.append(electricField.getStationStatusEnum().getMessage() + ",");
|
|
|
+ content.append(electricField.getName() + ",");
|
|
|
+ content.append(electricField.getSign() + ",");
|
|
|
+ content.append(electricField.getNetSubstationName() + ",");
|
|
|
+ content.append(electricField.getCapacity() + ",");
|
|
|
+ content.append(electricField.getGridCE() + ",");
|
|
|
+ content.append(electricField.getLongitude() + ",");
|
|
|
+ content.append(electricField.getLatitude() + ",");
|
|
|
+ content.append(electricField.getElectricFieldTypeEnum().getMessage() + ",");
|
|
|
+ content.append(electricField.getProvinceEnum().getMessage() + ",");
|
|
|
+ content.append(electricField.getInterval() + ",");
|
|
|
+ content.append(electricField.getAltitude() + ",");
|
|
|
+ content.append(electricField.getCompany() + ",");
|
|
|
+ content.append(electricField.getLocation() + ",");
|
|
|
+ content.append(electricField.getArea() + ",");
|
|
|
+ content.append("\r\n");
|
|
|
+ }
|
|
|
+ templateContent.append(header);
|
|
|
+ templateContent.append(content.toString());
|
|
|
+ response.setContentType("application/x-msdownload;charset=UTF-8");// 文件下载必须配置为application/x-msdownload
|
|
|
+ response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode("场站信息数据.csv", "UTF-8"));// 中文文件名必须使用URLEncoder.encode进行转码
|
|
|
+ byte[] templateContentBytes = templateContent.toString().getBytes("UTF-8");
|
|
|
+ bos = new BufferedOutputStream(response.getOutputStream());// 向response中写入文件流
|
|
|
+ bos.write(new byte[]{(byte) 0xEF, (byte) 0xBB, (byte) 0xBF});// 指定csv文件用UTF-8字符集打开
|
|
|
+ bos.write(templateContentBytes);
|
|
|
+ response.flushBuffer();
|
|
|
+ templateContent = null;
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("系统错误:" + e.getMessage(), e);
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ } finally {
|
|
|
+ if (bos != null)
|
|
|
+ try {
|
|
|
+ bos.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("系统错误:" + e.getMessage(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|