浏览代码

程序移植

wanghc 3 年之前
父节点
当前提交
6ea275cb5e

+ 48 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/FileAnalysisRecord.java

@@ -0,0 +1,48 @@
+package com.jiayue.ipfcst.common.data.entity;
+
+import com.jiayue.ipfcst.common.data.abst.AbstractBaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.hibernate.annotations.GenericGenerator;
+import org.springframework.core.annotation.Order;
+
+import javax.persistence.*;
+
+/**
+ * 文件解析记录
+ *
+ * @author cuil
+ * @version 2.0
+ * @since 2018/12/29 15:21
+ */
+@EqualsAndHashCode(callSuper = true)
+@Entity
+@Data
+public class FileAnalysisRecord extends AbstractBaseEntity {
+    @Id
+    @Order(1)
+    @GeneratedValue(strategy = GenerationType.AUTO, generator = "myid")
+    @GenericGenerator(name = "myid", strategy = "com.jiayue.ipfcst.common.data.entity.id.CustomIDGenerator")
+    private Integer id;
+    /*文件名称*/
+    @Column
+    private String fileTitle;
+    /*文件类型 */ 
+    @Column
+    private String fileType;
+    /*文件描述*/
+    @Column(length = 256)
+    private String fileDescription;
+    /*文件存放路径*/
+    @Column(length = 256)
+    private String filePath;
+    /*文件解析状态 1:成功 0:失败*/
+    @Column
+    private String fileStatus;
+    /*场站编号*/
+    @Column
+    private String stationCode;
+
+    // 高精度数据使用   @Digits(integer = 5, fraction = 2) @Column private BigDecimal weight;
+
+}

+ 59 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/FileCreateLog.java

@@ -0,0 +1,59 @@
+package com.jiayue.ipfcst.common.data.entity;
+
+import lombok.Data;
+
+/**
+ * 文件生成列表
+ *
+ * @author bizy
+ * @version 3.0
+ */
+@Data
+public class FileCreateLog {
+    private String id;
+
+    /**
+     * 场站编码
+     */
+    private String stationCode;
+
+    /**
+     * 场站名称
+     */
+    private String stationName;
+
+    /**
+     * 文件名
+     */
+    private String fileName;
+
+    /**
+     * 文件存放路径
+     */
+    private String filePath;
+
+    /**
+     * 日期
+     */
+    private String fileDate;
+
+    /**
+     * 是否下载
+     */
+    private String fileDownLoadStatus;
+
+    /**
+     * 是否传入内网
+     */
+    private String fileInStatus;
+
+    /**
+     * 下载到外网的方式
+     */
+    private String fileDownLoadType;
+
+    /**
+     * 文件类型
+     */
+    private String fileType;
+}

+ 7 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/SysParameterRepository.java

@@ -2,6 +2,7 @@ package com.jiayue.ipfcst.common.data.repository;
 
 import com.jiayue.ipfcst.common.data.entity.SysParameter;
 
+import java.util.List;
 import java.util.Optional;
 
 /**
@@ -14,7 +15,12 @@ import java.util.Optional;
 public interface SysParameterRepository extends BaseRepository<SysParameter, Integer> {
 	Optional<SysParameter> findBySysKeyAndStationCode(String sysKey,String stationCode);
 
-	Boolean existsBySysKey(String sysKey);
+	Boolean existsBySysKeyAndStationCode(String sysKey,String stationCode);
 
 	SysParameter findBySysKeyEquals(String sysKey);
+
+	List<SysParameter>findAllByStationCode(String stationCode);
+
+	void deleteByStationCode(String stationCode);
+
 }

+ 22 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/aop/SaveValidate.java

@@ -0,0 +1,22 @@
+package com.jiayue.ipfcst.aop;
+
+import java.lang.annotation.*;
+
+/**
+ * 保存校验注解
+ *
+ * @author bizy
+ * @version 3.0
+ */
+@Inherited
+@Target({
+        ElementType.TYPE, ElementType.METHOD
+})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface SaveValidate {
+    /**
+     * 方法描述
+     */
+    String desc() default "";
+}

+ 581 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/ElectricFieldController.java

@@ -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);
+                }
+        }
+
+    }
+
+}

+ 139 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/SysParameterController.java

@@ -0,0 +1,139 @@
+package com.jiayue.ipfcst.console.controller;
+
+import com.jiayue.ipfcst.aop.SaveValidate;
+import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
+import com.jiayue.ipfcst.common.data.entity.SysParameter;
+import com.jiayue.ipfcst.console.service.SysParameterService;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 系统参数restful接口
+ *
+ * @author tl
+ * @version 3.0
+ * @since 2020/6/28 9:10
+ */
+@RestController
+@RequestMapping(value = "sysParameter")
+@Slf4j
+public class SysParameterController {
+
+    private final SysParameterService sysParameterService;
+
+    @Autowired
+    public SysParameterController(SysParameterService sysParameterService) {
+      this.sysParameterService = sysParameterService;
+    }
+
+    /**
+     * 新增系统参数
+     *
+     * @param sysParameter 参数
+     * @return 执行结果
+     */
+    @SneakyThrows
+    @PostMapping()
+    @SaveValidate
+    public ResponseVO add(@RequestBody SysParameter sysParameter) {
+      try {
+        this.sysParameterService.add(sysParameter);
+        return ResponseVO.success(1);
+      } catch (Exception ex) {
+        log.error("系统错误" + ex);
+        return ResponseVO.error(ex);
+      }
+
+    }
+
+    /**
+     * 修改系统参数
+     *
+     * @param sysParameter 参数
+     * @return 执行结果
+     */
+    @SneakyThrows
+    @SaveValidate
+    @PutMapping()
+    public ResponseVO update(@RequestBody SysParameter sysParameter) {
+      this.sysParameterService.update(sysParameter);
+      return ResponseVO.success(1);
+    }
+
+    /**
+     * 删除系统参数
+     *
+     * @param sysParameter 参数
+     * @return 执行结果
+     */
+    @SneakyThrows
+    @SaveValidate
+    @DeleteMapping()
+    public ResponseVO delete(@RequestBody SysParameter sysParameter) {
+      this.sysParameterService.delete(sysParameter.getId());
+      return ResponseVO.success(1);
+    }
+
+
+    /**
+     * 获取所有系统参数
+     *
+     * @return 执行结果
+     */
+    @SneakyThrows
+    @GetMapping(value = "/sysParameter/{stationCode}/")
+    public ResponseVO getAll(@PathVariable("stationCode") String stationCode) {
+      List<SysParameter> list = this.sysParameterService.getAll(stationCode);
+      return ResponseVO.success(list);
+    }
+
+
+    /**
+     * 获取系统参数
+     *
+     * @param page
+     * @param size
+     * @return 执行结果
+     */
+    @SneakyThrows
+    @GetMapping(value = "/{page}/{size}")
+    public ResponseVO getAll(@PathVariable("page") Integer page, @PathVariable("size") Integer size) {
+      SysParameter sysParameter = new SysParameter();
+      Page<SysParameter> sysParameterPage = this.sysParameterService.get(sysParameter, page, size);
+      return ResponseVO.success(sysParameterPage);
+    }
+
+
+  /**
+   * 获取系统参数
+   *
+   * @param page
+   * @param size
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @GetMapping(value = "/{page}/{size}/{keywords}")
+  public ResponseVO getAForKeywords(@PathVariable("page") Integer page, @PathVariable("size") Integer size,@PathVariable("keywords") String keywords) {
+    SysParameter sysParameter = new SysParameter();
+    Page<SysParameter> sysParameterPage = this.sysParameterService.getForKeywords(sysParameter, page, size,keywords);
+    return ResponseVO.success(sysParameterPage);
+  }
+
+    /**
+     * 根据参数标识获取系统参数
+     *
+     * @param id
+     * @return 执行结果
+     */
+    @SneakyThrows
+    @GetMapping(value = "/sysParameter/{id}/")
+    public ResponseVO getById(@PathVariable("sysKey") Integer id) {
+      return ResponseVO.success(sysParameterService.getParameter(id));
+    }
+
+}

+ 11 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/ElectricFieldService.java

@@ -12,6 +12,8 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.List;
+
 /**
  * 场站信息业务层
  *
@@ -71,4 +73,13 @@ public class ElectricFieldService extends BaseService {
     }
     return electricField;
   }
+
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public ElectricField getOne(String stationCode){
+    return electricFieldRepository.getOne(stationCode);
+  }
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public List<ElectricField> getAll(){
+    return electricFieldRepository.findAll();
+  }
 }

+ 185 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/OverHaulPlanService.java

@@ -0,0 +1,185 @@
+package com.jiayue.ipfcst.console.service;
+
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.json.JSONObject;
+import com.jiayue.ipfcst.common.core.exception.BusinessException;
+import com.jiayue.ipfcst.common.core.util.JsonBeanUtil;
+import com.jiayue.ipfcst.common.data.entity.ElectricField;
+import com.jiayue.ipfcst.common.data.entity.OverhaulPlan;
+import com.jiayue.ipfcst.common.data.repository.ElectricFieldRepository;
+import com.jiayue.ipfcst.common.data.repository.OverhaulPlanRepository;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.*;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 检修计划业务层
+ *
+ * @author Tangle
+ * @version 1.0
+ * @since 2020/03/27 10:02
+ */
+@Service
+@Slf4j
+public class OverHaulPlanService {
+  private final OverhaulPlanRepository overhaulPlanRepository;
+
+  private final ElectricFieldRepository electricFieldRepository;
+
+  @Autowired
+  public OverHaulPlanService(OverhaulPlanRepository overhaulPlanRepository, ElectricFieldRepository electricFieldRepository) {
+    this.overhaulPlanRepository = overhaulPlanRepository;
+    this.electricFieldRepository = electricFieldRepository;
+  }
+
+  /**
+   * 新增检修计划
+   *
+   * @param overhaulPlan 检修计划实体
+   */
+  public void add(OverhaulPlan overhaulPlan) {
+    overhaulPlan.setFinalEntryTime(overhaulPlan.getStartTime());
+    this.overhaulPlanRepository.save(overhaulPlan);
+  }
+
+  /**
+   * 修改检修计划信息
+   *
+   * @param overhaulPlan
+   * @throws BusinessException
+   */
+  public void save(OverhaulPlan overhaulPlan) throws BusinessException {
+    if (overhaulPlan.getId() == null) {
+      throw new BusinessException("修改时主键不能为空");
+    } else {
+      Calendar calendar = Calendar.getInstance();
+      if (overhaulPlan.getStatus() == 2) {
+        calendar.setTime(new Date());
+        overhaulPlan.setMcTime(calendar.getTimeInMillis());
+      }
+      overhaulPlan.setFinalEntryTime(overhaulPlan.getStartTime());
+      this.overhaulPlanRepository.save(overhaulPlan);
+    }
+  }
+
+  /**
+   * 删除检修计划信息
+   *
+   * @param id 主键
+   */
+  public void delete(final Integer id) {
+    this.overhaulPlanRepository.deleteById(id);
+  }
+
+  /**
+   * 查询检修计划信息(分页)
+   */
+  public Page<OverhaulPlan> get(final OverhaulPlan overhaulPlan, final Integer page, final Integer size) {
+    getAll();
+    ExampleMatcher matcher =
+      ExampleMatcher.matching().withMatcher("id", ExampleMatcher.GenericPropertyMatchers.contains());
+    Example<OverhaulPlan> example = Example.of(overhaulPlan, matcher);
+    Pageable pageable = PageRequest.of(page - 1, size);
+    return overhaulPlanRepository.findAll(example, pageable);
+
+  }
+
+  /**
+   * 查询检修计划信息
+   */
+  @Transactional
+  public List<OverhaulPlan> getAll() {
+    List<OverhaulPlan> overhaulPlans = overhaulPlanRepository.findAll();
+    List<OverhaulPlan> overhaulPlansResult = new ArrayList<>();
+    overhaulPlans.forEach(s->{
+      long a = s.getEndTime();
+      long b = System.currentTimeMillis();
+      if(a< b){
+        s.setStatus(2);
+        overhaulPlanRepository.save(s);
+      }
+      overhaulPlansResult.add(s);
+    });
+
+
+    return overhaulPlansResult;
+
+  }
+
+  /**
+   * 计算出距离当前最近且在当前时间之后的时间
+   *
+   * @return
+   */
+  public OverhaulPlan findByNextTime() {
+
+    List<OverhaulPlan> overhaulPlanList = overhaulPlanRepository.findAll();
+    OverhaulPlan overhaulPlan1 = new OverhaulPlan();
+    overhaulPlan1.setStartTime(0l);
+    if (overhaulPlanList.size() > 0) {
+
+      Long time = System.currentTimeMillis();
+      for (OverhaulPlan overhaulPlan : overhaulPlanList) {
+        if (overhaulPlan.getStartTime() > time) {
+          Long difference = overhaulPlan.getStartTime() - time;
+          if (overhaulPlan1.getStartTime() == 0) {
+            overhaulPlan1 = overhaulPlan;
+          }
+          if (difference > 0l && difference < overhaulPlan1.getStartTime()) {
+            overhaulPlan1 = overhaulPlan;
+          }
+        }
+      }
+    }
+
+    return overhaulPlan1;
+  }
+
+
+  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+  public void saveCloud(List<OverhaulPlan> overhaulPlans) {
+    if (null != overhaulPlans && overhaulPlans.size() > 0) {
+      overhaulPlanRepository.deleteAll();
+      overhaulPlanRepository.saveAll(overhaulPlans);
+    }
+  }
+
+  /**
+   * 获取当前时间检修容量
+   */
+  public BigDecimal getOverhaulCapacity(){
+    BigDecimal overhaulCapacity = new BigDecimal(0);
+    long time = System.currentTimeMillis();
+    List<OverhaulPlan> overhaulPlans = overhaulPlanRepository.findByStartTimeLessThanAndEndTimeGreaterThanAndStatus(time, time, 1);
+    if(overhaulPlans.size()>0){
+      overhaulCapacity = overhaulPlans.get(0).getOverhaulCapactity();
+    }
+    return overhaulCapacity;
+  }
+
+
+  /**
+   * 获取taskNo编号
+   *
+   * @param electricField 场站对象
+   * @return 编号
+   */
+
+  private String getTaskNo(ElectricField electricField) {
+    Date date = DateUtil.date();
+    return electricField.getStationCode() + DateUtil.format(date, "yyMMddHHmmss");
+  }
+
+
+
+}

+ 164 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/SysParameterService.java

@@ -0,0 +1,164 @@
+package com.jiayue.ipfcst.console.service;
+
+import cn.hutool.core.util.StrUtil;
+import com.jiayue.ipfcst.common.core.exception.BusinessException;
+import com.jiayue.ipfcst.common.data.entity.SysParameter;
+import com.jiayue.ipfcst.common.data.repository.SysParameterRepository;
+import com.jiayue.ipfcst.common.data.service.BaseService;
+import lombok.extern.slf4j.Slf4j;
+import net.sf.ehcache.Cache;
+import net.sf.ehcache.Element;
+import net.sf.ehcache.search.Attribute;
+import net.sf.ehcache.search.Query;
+import net.sf.ehcache.search.Result;
+import net.sf.ehcache.search.Results;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.ehcache.EhCacheCacheManager;
+import org.springframework.data.domain.*;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * 系统参数业务层
+ *
+ * @author zzy
+ * @version 1.0
+ * @since 2019/8/6 16:35
+ */
+@Service
+@Slf4j
+public class SysParameterService extends BaseService {
+
+    private final SysParameterRepository sysParameterRepository;
+
+    @Autowired
+    public SysParameterService(SysParameterRepository sysParameterRepository) {
+        this.sysParameterRepository = sysParameterRepository;
+    }
+
+    /**
+     * 新增系统参数
+     *
+     * @param sysParameter 系统参数实体
+     * @throws BusinessException 业务异常
+     */
+    @Transactional(propagation = Propagation.SUPPORTS)
+    public void add(SysParameter sysParameter) throws BusinessException {
+
+        boolean b = this.sysParameterRepository.existsBySysKeyAndStationCode(sysParameter.getSysKey(),sysParameter.getStationCode());
+        if (b) {// 参数已存在
+            throw new BusinessException("系统参数已存在!");
+        } else {
+            this.sysParameterRepository.save(sysParameter);
+        }
+    }
+
+    /**
+     * 修改系统参数
+     *
+     * @param sysParameter 系统参数实体
+     * @throws BusinessException 业务异常
+     */
+    @Transactional(propagation = Propagation.SUPPORTS)
+    public void update(SysParameter sysParameter) throws BusinessException {
+        if (StrUtil.isEmpty(sysParameter.getSysKey())) {
+            throw new BusinessException("系统参数标识不能为空!");
+        } else {
+            this.sysParameterRepository.save(sysParameter);
+        }
+    }
+
+    /**
+     * 删除系统参数
+     *
+     * @param id 主键编号
+     * @throws BusinessException 业务异常
+     */
+    @Transactional(rollbackFor = Exception.class, propagation = Propagation.SUPPORTS)
+    public void delete(final Integer id) throws BusinessException {
+        this.sysParameterRepository.deleteById(id);
+
+    }
+
+
+    /**
+     * 查询参数
+     *
+     * @param sysParameter 查询条件
+     * @param page         页码
+     * @param size         每页记录数
+     * @return 分页结果
+     */
+    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+    public Page<SysParameter> get(final SysParameter sysParameter, final Integer page, final Integer size) {
+        ExampleMatcher matcher = ExampleMatcher.matching()
+                .withMatcher("sysKey", ExampleMatcher.GenericPropertyMatchers.contains())
+                .withMatcher("sysValue", ExampleMatcher.GenericPropertyMatchers.contains())
+                .withMatcher("describe", ExampleMatcher.GenericPropertyMatchers.contains());
+        Example<SysParameter> example = Example.of(sysParameter, matcher);
+        Pageable pageable = PageRequest.of(page - 1, size);
+        return this.sysParameterRepository.findAll(example, pageable);
+    }
+
+    /**
+     * 查询参数值
+     *
+     * @param id 主键编号
+     * @return 参数
+     */
+    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+    public String getParameter(final Integer id) {
+        Optional<SysParameter> sysParameterOptional = this.sysParameterRepository.findById(id);
+        return sysParameterOptional.map(SysParameter::getSysValue).orElse(null);
+    }
+
+
+
+    /**
+     * 查询所有参数信息
+     *
+     * @return 通道信息
+     */
+    public List<SysParameter> getAll(String stationCode) {
+
+        return sysParameterRepository.findAllByStationCode(stationCode);
+    }
+
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public void saveCloud(SysParameter bean) {
+        Optional<SysParameter> optional = sysParameterRepository.findBySysKeyAndStationCode(bean.getSysKey(), bean.getStationCode());
+        if (optional.isPresent()) {
+            bean.setId(optional.get().getId());
+        }
+        sysParameterRepository.save(bean);
+    }
+
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public void saveCloud(List<SysParameter> beans) {
+        if(beans != null && beans.size() > 0){
+            sysParameterRepository.deleteByStationCode(beans.get(0).getStationCode());
+            sysParameterRepository.saveAll(beans);
+        }
+    }
+
+    /**
+     * 根据描述查询告警信息
+     *
+     * @return 告警信息
+     */
+    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+    public Page<SysParameter> getForKeywords(SysParameter sysParameter, Integer page, Integer size, String keywords) {
+        sysParameter.setDescribe(keywords);
+        ExampleMatcher matcher = ExampleMatcher.matching().withMatcher("modelNumber", ExampleMatcher.GenericPropertyMatchers.contains())
+                .withMatcher("describe", ExampleMatcher.GenericPropertyMatchers.contains());
+        Example<SysParameter> example = Example.of(sysParameter, matcher);
+        Pageable pageable = PageRequest.of(page - 1, size);
+        return this.sysParameterRepository.findAll(example, pageable);
+    }
+
+}