Procházet zdrojové kódy

检修计划功能

wangtao před 3 roky
rodič
revize
c2e3de2aeb

+ 88 - 100
ipfcst-console/src/main/frontend/views/console/overHaulPlan/index.vue

@@ -3,37 +3,26 @@
     <el-card class="box-card">
     <el-card class="box-card">
       <div slot="header" class="clearfix">
       <div slot="header" class="clearfix">
         <span>检修计划</span>
         <span>检修计划</span>
-        <el-button style="float: right;padding:3px 10px 3px 3px;" type="text" @click="qrShow">二维码扫描上传
-        </el-button>
+
         <el-button style="float: right;padding:3px 10px 3px 3px;" type="text" @click="exportDataEvent">导出数据
         <el-button style="float: right;padding:3px 10px 3px 3px;" type="text" @click="exportDataEvent">导出数据
         </el-button>
         </el-button>
       </div>
       </div>
+      <span style="font-weight: bold;font-size: 14px">场站名称:</span>
+      <el-select style="width:250px" v-model="stationCode" size="small">
+        <el-option
+          v-for="item in stationList"
+          :key="item.stationCode"
+          :label="item.name"
+          :value="item.stationCode"
+        />
+      </el-select>
+      <el-button type="primary" size="small" @click="serachEvent" style="round-clip: 10px"
+                 :loading="btnLonding">查询
+      </el-button>
       <el-button type="primary" size="small" @click="insertEvent" style="round-clip: 10px"
       <el-button type="primary" size="small" @click="insertEvent" style="round-clip: 10px"
                  :loading="btnLonding">新增
                  :loading="btnLonding">新增
       </el-button>
       </el-button>
-      <div>
-        <el-dialog
-          :close-on-click-modal="false"
-          :visible.sync="dialogVisible"
-          title="请扫描以下二维码"
-          style="padding: 0px;"
-          label-width="1px"
-          width="500px">
-          <!--            <el-image-->
-          <!--              src="http://www.baidu.com"-->
-          <!--              fit="fill"-->
-          <!--            />-->
-          <div id="qrCode" ref="qrCodeDiv" name="qrCodeDiv" align="center"></div>
 
 
-          <span
-            slot="footer"
-            class="dialog-footer">
-            <el-button
-              size="mini"
-              @click="cancel">关 闭</el-button>
-          </span>
-        </el-dialog>
-      </div>
       <div style="padding-top: 10px">
       <div style="padding-top: 10px">
         <vxe-table
         <vxe-table
           highlight-hover-row
           highlight-hover-row
@@ -88,10 +77,8 @@
                 }}
                 }}
               </template>
               </template>
             </vxe-table-column>
             </vxe-table-column>
-            <!--            <vxe-table-column width="15%" field="finalEntryTime" title="生效时间"-->
-            <!--                              :edit-render="{}">-->
-            <!--              <template v-slot="{ row }">{{ timestampToTime(row.finalEntryTime) }}</template>-->
-            <!--            </vxe-table-column>-->
+            <vxe-table-column field="stationCode" title="场站编码"
+                              :edit-render="{name:'$input',attrs:{type:'text'}}"></vxe-table-column>
             <vxe-table-column field="overhaulCapactity" title="检修容量(Mw)"
             <vxe-table-column field="overhaulCapactity" title="检修容量(Mw)"
                               :edit-render="{name:'$input',attrs:{type:'text'}}"></vxe-table-column>
                               :edit-render="{name:'$input',attrs:{type:'text'}}"></vxe-table-column>
             <vxe-table-column field="status" title="计划状态">
             <vxe-table-column field="status" title="计划状态">
@@ -174,18 +161,17 @@
   </div>
   </div>
 </template>
 </template>
 <script>
 <script>
-import request from '@/utils/request'
-import QRCode from 'qrcodejs2';
 export default {
 export default {
   data() {
   data() {
     return {
     return {
       now: new Date().getTime(),
       now: new Date().getTime(),
       checkSign: '',
       checkSign: '',
       checkTableDate: [],
       checkTableDate: [],
+      stationList: [],
       holidayType: '',
       holidayType: '',
+      stationCode: '',
       loading: false,
       loading: false,
       dialogVisible: false,
       dialogVisible: false,
-      generateOverHaulPlanCodeContentData:'',
       saveLoding: false,
       saveLoding: false,
       showTable: true,
       showTable: true,
       btnLonding: false,
       btnLonding: false,
@@ -194,7 +180,7 @@ export default {
       pageSize: 10,
       pageSize: 10,
       total: 0,
       total: 0,
       elCapacity: 0,
       elCapacity: 0,
-      startTimeShow:false,
+      startTimeShow: false,
       //表单验证规则
       //表单验证规则
       rules: {
       rules: {
         name: [
         name: [
@@ -209,29 +195,44 @@ export default {
           {required: true, message: '开始时间不能为空'}
           {required: true, message: '开始时间不能为空'}
         ],
         ],
         overhaulCapactity: [
         overhaulCapactity: [
-          { required: true, message: '不能为空' },
-          { pattern: /^\d+(\.\d{2})?$/, message: '只能输入正数数字或带两位小数的数字' }
+          {required: true, message: '不能为空'},
+          {pattern: /^\d+(\.\d{2})?$/, message: '只能输入正数数字或带两位小数的数字'}
           // {message: '输入过长', max: 50}
           // {message: '输入过长', max: 50}
 
 
-        ]
+        ],
+        stationCode: [
+          {required: true, message: ' 场站编码不能为空'},
+          {min: 1, max: 6, message: '称长度在 1 到 6 个字符'}
+        ],
       },
       },
       //当前日期之前日期不可选
       //当前日期之前日期不可选
       pickerOptions1: {
       pickerOptions1: {
         disabledDate(time) {
         disabledDate(time) {
           return time.getTime() < Date.now() - 8.64e7;
           return time.getTime() < Date.now() - 8.64e7;
-          // return time.getTime() <= Date.now();
+
         }
         }
       }
       }
     }
     }
   },
   },
   created() {
   created() {
-    this.getEl()
+    this.get(),
+      this.getAll()
   },
   },
   methods: {
   methods: {
-    getEl() {
-      this.$axios.get("/electricField/").then(response => {
-        this.elCapacity = response.data.capacity
-        this.getAll()
+    //查询场站信息
+    get() {
+      Promise.all([this.getStationList()]).then((res) => {
+        this.stationList = res[0]
+      })
+    },
+    getStationList() {
+      const a = this.$axios
+      return new Promise(function (resolve, reject) {
+        a.get('/electricField/getElectricField').then(res => {
+          resolve(res.data)
+        }).catch((error) => {
+          this.$message.error('获取场站下拉框出错' + error)
+        })
       })
       })
     },
     },
     getAll() {
     getAll() {
@@ -241,7 +242,6 @@ export default {
       this.$axios.get("/overHaulPlan/" + this.currentPage + '/' + this.pageSize).then(response => {
       this.$axios.get("/overHaulPlan/" + this.currentPage + '/' + this.pageSize).then(response => {
         if (response.data.content == "") {
         if (response.data.content == "") {
           this.showTable = false
           this.showTable = false
-
         } else {
         } else {
           this.showTable = true
           this.showTable = true
         }
         }
@@ -253,20 +253,20 @@ export default {
           this.total = response.data.totalElements
           this.total = response.data.totalElements
         }
         }
         this.loading = false
         this.loading = false
-
       })
       })
-      this.generateOverHaulPlanCodeContent()
+
     },
     },
     //编辑框改变
     //编辑框改变
     editRowEvent(row) {
     editRowEvent(row) {
       this.startTimeShow = false
       this.startTimeShow = false
-      if(row.startTime < new Date().getTime()){
+      if (row.startTime < new Date().getTime()) {
         this.startTimeShow = true
         this.startTimeShow = true
       }
       }
       this.checkSign = true
       this.checkSign = true
       this.btnLonding = true
       this.btnLonding = true
       this.$refs.xTable.setActiveRow(row)
       this.$refs.xTable.setActiveRow(row)
     },
     },
+    //检查检修计划时间是否重叠
     checkDate(v1, v2, v3, v4) {
     checkDate(v1, v2, v3, v4) {
       let result = false
       let result = false
       const item = ''
       const item = ''
@@ -276,7 +276,7 @@ export default {
 
 
       // 在修改时,把当前在所有信息集合里要修改的信息去掉(如果不去掉会影响校验)
       // 在修改时,把当前在所有信息集合里要修改的信息去掉(如果不去掉会影响校验)
       for (let i = 0; i < v2.length; i++) {
       for (let i = 0; i < v2.length; i++) {
-        if (v2[i].id == v4.id||v2[i].status == 2) {
+        if (v2[i].id == v4.id || v2[i].status == 2) {
           continue
           continue
         }
         }
         v5.push(v2[i])
         v5.push(v2[i])
@@ -324,25 +324,38 @@ export default {
       }
       }
       return result
       return result
     },
     },
+    checkCap(stationCode, cap) {
+      this.$axios.get("/electricField/getElectricField/" + stationCode).then(response => {
+        this.elCapacity = response.data.capacity
+      })
+      if (cap <= this.elCapacity) {
+        return true
+      } else {
+        return false
+      }
+    },
     //数据校验
     //数据校验
     saveCheck(row) {
     saveCheck(row) {
 
 
       this.$refs.xTable.validate(row, callback => {
       this.$refs.xTable.validate(row, callback => {
-        if(row.startTime<new Date().getTime()&&!this.startTimeShow){
-          this.$XModal.message({status: 'error', message: '开始时间不能小于当前时间!'})
-        }else if(row.overhaulCapactity>this.elCapacity){
+        if (!this.checkCap(row.stationCode, row.overhaulCapactity)) {
           this.$XModal.message({status: 'error', message: '检修容量不能大于装机容量!'})
           this.$XModal.message({status: 'error', message: '检修容量不能大于装机容量!'})
-        } else if (row.startTime == null || row.endTime == null) {
-          // callback(new Error('开始结束日期不能为空'))
-          this.$XModal.message({status: 'error', message: '开始结束日期不能为空!'})
         } else {
         } else {
-          var timeStartEnd = [row.startTime,row.endTime]
-          if (this.checkDate(timeStartEnd, this.tableData, this.checkSign, row)) {
-            this.$XModal.message({status: 'error', message: '该时间段已有检修计划!'})
+          if (row.startTime < new Date().getTime() && !this.startTimeShow) {
+            this.$XModal.message({status: 'error', message: '开始时间不能小于当前时间!'})
+          } else if (row.startTime == null || row.endTime == null) {
+            this.$XModal.message({status: 'error', message: '开始结束日期不能为空!'})
           } else {
           } else {
-            callback:this.saveRowEvent(row)
+
+            var timeStartEnd = [row.startTime, row.endTime]
+            if (this.checkDate(timeStartEnd, this.tableData, this.checkSign, row)) {
+              this.$XModal.message({status: 'error', message: '该时间段已有检修计划!'})
+            } else {
+              callback:this.saveRowEvent(row)
+            }
           }
           }
         }
         }
+
       })
       })
     },
     },
     //保存数据操作
     //保存数据操作
@@ -362,7 +375,6 @@ export default {
               this.getAll()
               this.getAll()
               this.$XModal.message({status: 'warning', message: response.message})
               this.$XModal.message({status: 'warning', message: response.message})
               this.saveLoding = false
               this.saveLoding = false
-
             })
             })
           }
           }
           this.btnLonding = false
           this.btnLonding = false
@@ -452,48 +464,30 @@ export default {
       this.$refs.xTable.insert()
       this.$refs.xTable.insert()
         .then(({row}) => this.$refs.xTable.setActiveRow(row))
         .then(({row}) => this.$refs.xTable.setActiveRow(row))
     },
     },
+    serachEvent() {
+      this.now = (new Date()).getTime()
+      this.loading = true
+      this.saveLoding = false
+      this.$axios.get("/overHaulPlan/" + this.currentPage + '/' + this.pageSize + '/' + this.stationCode).then(response => {
+
+        this.tableData = response.data.content
+        this.total = response.data.count
+
+        if (response.data.totalElements != 0) {
+
+          this.total = response.data.totalElements
+        }
+
+        this.loading = false
+      })
+    },
     //分页出发事件
     //分页出发事件
     handlePageChange({currentPage, pageSize}) {
     handlePageChange({currentPage, pageSize}) {
       this.currentPage = currentPage
       this.currentPage = currentPage
       this.pageSize = pageSize
       this.pageSize = pageSize
       this.getAll()
       this.getAll()
     },
     },
-    /*handleSizeChange(size) {
-        this.pageSize = size
-        this.getAll()
-    },
-    handleCurrentChange(currentPage) {
-        this.currentPage = currentPage
-        this.getAll()
-    },*/
-    //导出
-    qrShow(){
-      this.dialogVisible = true
-      this.$nextTick(() => {
-        var divs = document.getElementsByName('qrCodeDiv')
-        for(var j = 0;j<divs.length;j++){
-          divs[j].innerHTML = ""
-        }
-        new QRCode(this.$refs.qrCodeDiv, {
-          text: this.generateOverHaulPlanCodeContentData[0],
-          width: 300,
-          height: 300,
-          colorDark: "#333333", //二维码颜色
-          colorLight: "#ffffff", //二维码背景色
-          correctLevel: QRCode.CorrectLevel.L//容错率,L/M/H
-        })
-      })
-
-    },
-    generateOverHaulPlanCodeContent(){
-      this.$axios.get("/overHaulPlan/generateOverHaulPlanCodeContent").then(response => {
-        console.log(response.data)
-        this.generateOverHaulPlanCodeContentData =  response.data
-      })
-
-    },
-    cancel(){
-
+    cancel() {
       this.dialogVisible = false
       this.dialogVisible = false
     },
     },
     exportDataEvent() {
     exportDataEvent() {
@@ -501,7 +495,7 @@ export default {
       this.$axios.get('/overHaulPlan/').then(res => {
       this.$axios.get('/overHaulPlan/').then(res => {
         const data = res.data
         const data = res.data
 
 
-        for(let i = 0;i<data.length;i++){
+        for (let i = 0; i < data.length; i++) {
           data[i].startTime = this.timestampToTime1(data[i].startTime)
           data[i].startTime = this.timestampToTime1(data[i].startTime)
           data[i].endTime = this.timestampToTime1(data[i].endTime)
           data[i].endTime = this.timestampToTime1(data[i].endTime)
           data[i].finalEntryTime = this.timestampToTime1(data[i].finalEntryTime)
           data[i].finalEntryTime = this.timestampToTime1(data[i].finalEntryTime)
@@ -530,12 +524,6 @@ export default {
 
 
 <style lang="scss" scoped>
 <style lang="scss" scoped>
 .app-container {
 .app-container {
-  /*left: 0;*/
-  /*width: 100%;*/
-  /*min-height: 100%;*/
-  /*height: auto;*/
-  /*background-image: linear-gradient(25deg, #05362d, #145d44, #24875d, #35b477)*/
-
 }
 }
 
 
 .pagination {
 .pagination {

+ 169 - 150
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/ElectricFieldController.java

@@ -4,9 +4,9 @@ import com.jiayue.ipfcst.aop.SaveValidate;
 import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
 import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
 import com.jiayue.ipfcst.common.data.constant.enums.ElectricFieldTypeEnum;
 import com.jiayue.ipfcst.common.data.constant.enums.ElectricFieldTypeEnum;
 import com.jiayue.ipfcst.common.data.entity.ElectricField;
 import com.jiayue.ipfcst.common.data.entity.ElectricField;
-
-import com.jiayue.ipfcst.console.service.*;
-
+import com.jiayue.ipfcst.console.service.ElectricFieldService;
+import com.jiayue.ipfcst.console.service.OverHaulPlanService;
+import com.jiayue.ipfcst.console.service.SysParameterService;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
@@ -32,14 +32,14 @@ import java.util.Map;
 @Slf4j
 @Slf4j
 public class ElectricFieldController {
 public class ElectricFieldController {
 
 
-    @Autowired
-    ElectricFieldService electricFieldService;
+  @Autowired
+  ElectricFieldService electricFieldService;
 
 
-    @Autowired
-    SysParameterService sysParameterService;
+  @Autowired
+  SysParameterService sysParameterService;
 
 
-    @Autowired
-    OverHaulPlanService overHaulPlanService;
+  @Autowired
+  OverHaulPlanService overHaulPlanService;
 
 
    /* @Autowired
    /* @Autowired
     InverterInfoService inverterInfoService;
     InverterInfoService inverterInfoService;
@@ -80,111 +80,130 @@ public class ElectricFieldController {
     @Autowired
     @Autowired
     ProtocolGatherDataPointService protocolGatherDataPointService;*/
     ProtocolGatherDataPointService protocolGatherDataPointService;*/
 
 
-    /**
-     * 新增场站信息
-     *
-     * @param electricField 场站实体参数
-     * @return 执行结果
-     */
-    @PostMapping(value = "/")
-    @SaveValidate
-    public ResponseVO saveElectricField(@RequestBody ElectricField electricField) {
-        try {
-            electricFieldService.add(electricField);
-            return ResponseVO.success();
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error(" 保存场站信息异常");
-            return ResponseVO.fail();
-        }
-
+  /**
+   * 新增场站信息
+   *
+   * @param electricField 场站实体参数
+   * @return 执行结果
+   */
+  @PostMapping(value = "/")
+  @SaveValidate
+  public ResponseVO saveElectricField(@RequestBody ElectricField electricField) {
+    try {
+      electricFieldService.add(electricField);
+      return ResponseVO.success();
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error(" 保存场站信息异常");
+      return ResponseVO.fail();
     }
     }
 
 
-
-    /**
-     * 更新场站信息
-     *
-     * @param electricField 场站实体参数
-     * @return 执行结果
-     */
-    @PostMapping(value = "/updateElectricField")
-    @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();
-        }
-
+  }
+
+
+  /**
+   * 更新场站信息
+   *
+   * @param electricField 场站实体参数
+   * @return 执行结果
+   */
+  @PostMapping(value = "/updateElectricField")
+  @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 = "/getElectricField")
-    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);
-        }
+  }
+
+  /**
+   * 获取场站信息
+   *
+   * @return 所有场站信息
+   */
+
+  @GetMapping(value = "/getElectricField")
+  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);
+    }
 
 
+  }
+
+  /**
+   * 获取场站信息
+   *
+   * @return 所有场站信息
+   */
+
+  @GetMapping(value = "/getElectricField/{stationCode}")
+  public ResponseVO getElectricFieldByStationCode(@PathVariable String stationCode) {
+    try {
+      ElectricField electricField = this.electricFieldService.findByStationCode(stationCode);
+      return ResponseVO.success(electricField);
+    } 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();
-        }
 
 
+  @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 = "/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);
-        }
-
+  }
+
+  /**
+   * 功能描述: <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);
     }
     }
 
 
+  }
+
 
 
 
 
 
 
@@ -464,57 +483,57 @@ public class ElectricFieldController {
         }
         }
     }*/
     }*/
 
 
-    //导出所有场站
-    @RequestMapping(value = "/export")
-    public void export(HttpServletResponse response) {
-        BufferedOutputStream bos = null;
+  //导出所有场站
+  @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.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.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 {
         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.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.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);
-                }
+          bos.close();
+        } catch (IOException e) {
+          log.error("系统错误:" + e.getMessage(), e);
         }
         }
-
     }
     }
 
 
+  }
+
 }
 }

+ 108 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/OverHaulOlanController.java

@@ -0,0 +1,108 @@
+package com.jiayue.ipfcst.console.controller;
+
+import com.jiayue.ipfcst.common.core.exception.BusinessException;
+import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
+import com.jiayue.ipfcst.common.data.entity.OverhaulPlan;
+import com.jiayue.ipfcst.console.service.OverHaulPlanService;
+import lombok.SneakyThrows;
+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/03/27 10:12
+ */
+@RestController
+@RequestMapping("overHaulPlan")
+public class OverHaulOlanController {
+  final private OverHaulPlanService overHaulPlanService;
+
+  @Autowired
+  public OverHaulOlanController(OverHaulPlanService overHaulPlanService) {
+    this.overHaulPlanService = overHaulPlanService;
+  }
+
+  /**
+   * 新增 检修计划接口
+   *
+   * @param overhaulPlan
+   * @return 操作结果
+   */
+
+  @PostMapping
+  public ResponseVO insert(@RequestBody OverhaulPlan overhaulPlan) {
+    this.overHaulPlanService.add(overhaulPlan);
+    return ResponseVO.success(1);
+  }
+
+  /**
+   * 修改 检修计划接口
+   */
+  @PutMapping
+  public ResponseVO update(@RequestBody OverhaulPlan overhaulPlan) throws BusinessException {
+    this.overHaulPlanService.save(overhaulPlan);
+    return ResponseVO.success(1);
+  }
+
+  /**
+   * 删除 检修计划接口
+   *
+   * @param overhaulPlan
+   * @return 操作结果
+   */
+  @DeleteMapping
+  public ResponseVO delete(@RequestBody OverhaulPlan overhaulPlan) {
+    this.overHaulPlanService.delete(overhaulPlan.getId());
+    return ResponseVO.success(1);
+  }
+
+  /**
+   * 获取 检修计划接口
+   *
+   * @param page 页码
+   * @param size 条数
+   * @return 操作结果
+   */
+  @SneakyThrows
+  @GetMapping(value = "/{page}/{size}")
+  public ResponseVO get(@PathVariable("page") Integer page, @PathVariable("size") Integer size) {
+    OverhaulPlan overhaulPlan = new OverhaulPlan();
+    Page<OverhaulPlan> overhaulPlanCalendarPage = this.overHaulPlanService.get(overhaulPlan, page, size);
+    return ResponseVO.success(overhaulPlanCalendarPage);
+  }
+
+  /**
+   * 获取 检修计划接口
+   *
+   * @param page 页码
+   * @param size 条数
+   * @return 操作结果
+   */
+  @SneakyThrows
+  @GetMapping(value = "/{page}/{size}/{stationCode}")
+  public ResponseVO getByStationCode(@PathVariable("page") Integer page, @PathVariable("size") Integer size, @PathVariable("stationCode") String stationCode) {
+    OverhaulPlan overhaulPlan = new OverhaulPlan();
+    Page<OverhaulPlan> overhaulPlanCalendarPage = this.overHaulPlanService.getByStationCode(overhaulPlan, page, size, stationCode);
+    return ResponseVO.success(overhaulPlanCalendarPage);
+  }
+
+  /**
+   * 获取全部 检修计划接口
+   *
+   * @return 操作结果
+   */
+  @SneakyThrows
+  @GetMapping()
+  public ResponseVO getAll() {
+    OverhaulPlan overhaulPlan = new OverhaulPlan();
+    List<OverhaulPlan> list = this.overHaulPlanService.getAll();
+    return ResponseVO.success(list);
+  }
+
+}

+ 10 - 4
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/ElectricFieldService.java

@@ -58,11 +58,12 @@ public class ElectricFieldService extends BaseService {
    * 删除场站信息
    * 删除场站信息
    */
    */
   @Transactional(propagation = Propagation.SUPPORTS)
   @Transactional(propagation = Propagation.SUPPORTS)
-  public void delete(String stationCode){
+  public void delete(String stationCode) {
     electricFieldRepository.deleteById(stationCode);
     electricFieldRepository.deleteById(stationCode);
   }
   }
 
 
-  public ElectricField getSingleStation(String stationCode){
+  @Override
+  public ElectricField getSingleStation(String stationCode) {
     ElectricField electricField = null;
     ElectricField electricField = null;
     try {
     try {
       electricField = super.getSingleStation(stationCode);
       electricField = super.getSingleStation(stationCode);
@@ -73,11 +74,16 @@ public class ElectricFieldService extends BaseService {
   }
   }
 
 
   @Transactional(propagation = Propagation.SUPPORTS)
   @Transactional(propagation = Propagation.SUPPORTS)
-  public ElectricField getOne(String stationCode){
+  public ElectricField getOne(String stationCode) {
     return electricFieldRepository.getOne(stationCode);
     return electricFieldRepository.getOne(stationCode);
   }
   }
+
   @Transactional(propagation = Propagation.SUPPORTS)
   @Transactional(propagation = Propagation.SUPPORTS)
-  public List<ElectricField> getAll(){
+  public List<ElectricField> getAll() {
     return electricFieldRepository.findAll();
     return electricFieldRepository.findAll();
   }
   }
+
+  public ElectricField findByStationCode(String stationCode) {
+    return electricFieldRepository.findByStationCode(stationCode);
+  }
 }
 }

+ 17 - 74
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/OverHaulPlanService.java

@@ -1,10 +1,6 @@
 package com.jiayue.ipfcst.console.service;
 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.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.entity.OverhaulPlan;
 import com.jiayue.ipfcst.common.data.repository.ElectricFieldRepository;
 import com.jiayue.ipfcst.common.data.repository.ElectricFieldRepository;
 import com.jiayue.ipfcst.common.data.repository.OverhaulPlanRepository;
 import com.jiayue.ipfcst.common.data.repository.OverhaulPlanRepository;
@@ -12,11 +8,8 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.*;
 import org.springframework.data.domain.*;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 
 
-import java.io.IOException;
-import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.Date;
@@ -95,16 +88,31 @@ public class OverHaulPlanService {
   }
   }
 
 
   /**
   /**
+   * 查询检修计划信息(分页)
+   */
+  public Page<OverhaulPlan> getByStationCode(final OverhaulPlan overhaulPlan, final Integer page, final Integer size, final String stationCode) {
+    getAll();
+    overhaulPlan.setStationCode(stationCode);
+    ExampleMatcher matcher =
+      ExampleMatcher.matching().withMatcher("id", ExampleMatcher.GenericPropertyMatchers.contains())
+        .withMatcher("stationCode", ExampleMatcher.GenericPropertyMatchers.contains());
+    Example<OverhaulPlan> example = Example.of(overhaulPlan, matcher);
+    Pageable pageable = PageRequest.of(page - 1, size);
+    return overhaulPlanRepository.findAll(example, pageable);
+
+  }
+
+  /**
    * 查询检修计划信息
    * 查询检修计划信息
    */
    */
   @Transactional
   @Transactional
   public List<OverhaulPlan> getAll() {
   public List<OverhaulPlan> getAll() {
     List<OverhaulPlan> overhaulPlans = overhaulPlanRepository.findAll();
     List<OverhaulPlan> overhaulPlans = overhaulPlanRepository.findAll();
     List<OverhaulPlan> overhaulPlansResult = new ArrayList<>();
     List<OverhaulPlan> overhaulPlansResult = new ArrayList<>();
-    overhaulPlans.forEach(s->{
+    overhaulPlans.forEach(s -> {
       long a = s.getEndTime();
       long a = s.getEndTime();
       long b = System.currentTimeMillis();
       long b = System.currentTimeMillis();
-      if(a< b){
+      if (a < b) {
         s.setStatus(2);
         s.setStatus(2);
         overhaulPlanRepository.save(s);
         overhaulPlanRepository.save(s);
       }
       }
@@ -116,70 +124,5 @@ public class OverHaulPlanService {
 
 
   }
   }
 
 
-  /**
-   * 计算出距离当前最近且在当前时间之后的时间
-   *
-   * @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");
-  }
-
-
 
 
 }
 }

+ 67 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/util/GzipUtil.java

@@ -0,0 +1,67 @@
+package com.jiayue.ipfcst.console.util;
+
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.codec.binary.Base64OutputStream;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.zip.GZIPOutputStream;
+
+/**
+ * @author wll
+ * @date 2020-04-20 10:55:39
+ */
+@Slf4j
+public class GzipUtil {
+
+    private static int packSize = 800;
+
+    public static List<String> zipList(String result) throws IOException {
+        return zipList(result, packSize);
+    }
+
+    private static List<String> zipList(String result, int packSize) throws IOException {
+
+        String zipResult = zip(result);
+        zipResult = zipResult.replace("\r\n", "");
+
+        double length = zipResult.length();
+        int packageNumber = (int) Math.ceil(length / packSize);
+
+        List<String> list = new ArrayList<String>();
+
+        for (int i = 0; i < packageNumber; i++) {
+            if (i == packageNumber - 1) {
+                list.add(zipResult.substring(i * packSize, (int) length));
+            } else if (i == 0) {
+                list.add(zipResult.substring(0, packSize));
+            } else {
+                list.add(zipResult.substring(i * packSize, (i + 1) * packSize));
+            }
+        }
+
+
+        return list;
+    }
+
+    public static String zip(String result) throws IOException {
+        log.debug("qrCode默认编码:"+Charset.defaultCharset().name());
+        log.debug("file.encoding:"+System.getProperty("file.encoding"));
+        byte[] bytes = result.getBytes("utf-8");
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        Base64OutputStream b64os = new Base64OutputStream(bos);
+        GZIPOutputStream gout = new GZIPOutputStream(b64os);
+        gout.write(bytes);
+        gout.close();
+        b64os.close();
+
+        byte b1[] = bos.toByteArray();
+        bos.close();
+        return new String(b1, "utf-8");
+    }
+
+}