jichaobo 3 лет назад
Родитель
Сommit
eb0f48da5f

+ 70 - 3
fiveep-controller/src/main/java/com/bizmatics/controller/web/WcBlackoutPlanController.java

@@ -1,14 +1,24 @@
 package com.bizmatics.controller.web;
 package com.bizmatics.controller.web;
 
 
 
 
-import org.springframework.web.bind.annotation.RequestMapping;
+import com.bizmatics.common.core.bean.ApiResult;
+import com.bizmatics.model.DeviceAttribute;
+import com.bizmatics.model.WcBlackoutPlan;
+import com.bizmatics.model.vo.DeviceAttributeVo;
+import com.bizmatics.model.vo.WcBlackoutPlanVo;
+import com.bizmatics.service.DeviceAttributeService;
+import com.bizmatics.service.WcBlackoutPlanService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
 
 
 import org.springframework.stereotype.Controller;
 import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Date;
+import java.util.List;
 
 
 /**
 /**
  * <p>
  * <p>
- *  前端控制器
+ * 前端控制器
  * </p>
  * </p>
  *
  *
  * @author ya
  * @author ya
@@ -18,5 +28,62 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("/wcBlackoutPlan")
 @RequestMapping("/wcBlackoutPlan")
 public class WcBlackoutPlanController {
 public class WcBlackoutPlanController {
 
 
+    @Autowired
+    private WcBlackoutPlanService wcBlackoutPlanService;
+
+    /**
+     * 停电计划-新增
+     *
+     * @param wcBlackoutPlan
+     * @return
+     */
+    @GetMapping("plannedOutageAdd")
+    public ApiResult<Void> plannedOutageAdd(@RequestBody WcBlackoutPlan wcBlackoutPlan) {
+        wcBlackoutPlanService.plannedOutageAdd(wcBlackoutPlan);
+        return ApiResult.success();
+    }
+
+
+    /**
+     * 停电计划-修改
+     *
+     * @param wcBlackoutPlan
+     * @return
+     */
+    @GetMapping("plannedOutageUpdate")
+    public ApiResult<Void> plannedOutageUpdate(@RequestBody WcBlackoutPlan wcBlackoutPlan) {
+        wcBlackoutPlanService.plannedOutageUpdate(wcBlackoutPlan);
+        return ApiResult.success();
+    }
+
+    /**
+     * 停电计划-注销
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping("plannedOutageDel")
+    public ApiResult<Void> plannedOutageDel(@RequestParam int id) {
+        wcBlackoutPlanService.plannedOutageDel(id);
+        return ApiResult.success();
+    }
+
+    /**
+     * 停电计划-查询
+     *
+     * @param startTime 开始时间
+     * @param endTime   结束时间
+     * @param type      状态 1.未执行 2.执行中 3.已执行
+     * @param id 停电计划ID
+     * @return
+     */
+    @GetMapping("plannedOutageList")
+    public ApiResult<List<WcBlackoutPlanVo>> plannedOutageList(@RequestParam(required = false) String startTime,
+                                                               @RequestParam( required = false) String endTime,
+                                                               @RequestParam(value = "type", required = false, defaultValue = "0") int type,
+                                                               @RequestParam(value = "id", required = false, defaultValue = "0") int id) {
+        return ApiResult.success(wcBlackoutPlanService.plannedOutageList(startTime, endTime, type,id));
+    }
+
 }
 }
 
 

+ 2 - 2
fiveep-model/src/main/java/com/bizmatics/model/WcBlackoutPlan.java

@@ -39,12 +39,12 @@ public class WcBlackoutPlan implements Serializable {
     /**
     /**
      * 开始时间
      * 开始时间
      */
      */
-    private LocalDateTime startTime;
+    private String startTime;
 
 
     /**
     /**
      * 结束时间
      * 结束时间
      */
      */
-    private LocalDateTime endTime;
+    private String endTime;
 
 
     /**
     /**
      * 联系人 
      * 联系人 

+ 78 - 0
fiveep-model/src/main/java/com/bizmatics/model/vo/WcBlackoutPlanVo.java

@@ -0,0 +1,78 @@
+package com.bizmatics.model.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author ya
+ * @since 2021-07-07
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class WcBlackoutPlanVo implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 站点ID
+     */
+    private Integer siteId;
+
+    /**
+     * 计划类型:1.计划检修停电、2.计划施工停电、3.客户申请停电
+     */
+    private Integer planType;
+
+    /**
+     * 开始时间
+     */
+    private LocalDateTime startTime;
+
+    /**
+     * 结束时间
+     */
+    private LocalDateTime endTime;
+
+    /**
+     * 联系人 
+     */
+    private String contacts;
+
+    /**
+     * 手机号
+     */
+    private String phone;
+
+    /**
+     * 使能标识:1可用;0不可用
+     */
+    private Integer enable;
+
+    /**
+     * 添加人
+     */
+    private String creator;
+
+    /**
+     * 添加时间
+     */
+    private LocalDateTime createTime;
+
+
+    private String siteName;
+
+}

+ 11 - 2
fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/WcBlackoutPlanMapper.java

@@ -1,11 +1,16 @@
 package com.bizmatics.persistence.mapper;
 package com.bizmatics.persistence.mapper;
 
 
-import com.bizmatics.model.WcBlackoutPlan;
 import com.bizmatics.common.mvc.base.CrudMapper;
 import com.bizmatics.common.mvc.base.CrudMapper;
+import com.bizmatics.model.WcBlackoutPlan;
+import com.bizmatics.model.vo.WcBlackoutPlanVo;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Date;
+import java.util.List;
 
 
 /**
 /**
  * <p>
  * <p>
- *  Mapper 接口
+ * Mapper 接口
  * </p>
  * </p>
  *
  *
  * @author ya
  * @author ya
@@ -13,4 +18,8 @@ import com.bizmatics.common.mvc.base.CrudMapper;
  */
  */
 public interface WcBlackoutPlanMapper extends CrudMapper<WcBlackoutPlan> {
 public interface WcBlackoutPlanMapper extends CrudMapper<WcBlackoutPlan> {
 
 
+    List<WcBlackoutPlanVo> plannedOutageList(@Param("startTime") String startTime,
+                                             @Param("endTime") String endTime,
+                                             @Param("type") int type,
+                                             @Param("id") int id);
 }
 }

+ 27 - 0
fiveep-persistence/src/main/resources/mapper/mysql/WcBlackoutPlanMapper.xml

@@ -16,4 +16,31 @@
         <result column="create_time" property="createTime" />
         <result column="create_time" property="createTime" />
     </resultMap>
     </resultMap>
 
 
+    <select id="plannedOutageList" resultType="com.bizmatics.model.vo.WcBlackoutPlanVo">
+        SELECT
+         a.*,b.site_name
+        FROM
+        wc_blackout_plan AS a
+        JOIN site AS b ON a.site_id = b.id
+        <where>
+            a.enable =1
+            <if test="startTime != null and endTime != null and startTime != '' and endTime != ''">
+                and a.create_time between #{startTime} and #{endTime}
+            </if>
+            <if test="type == 1">
+                and a.start_time>now()
+            </if>
+            <if test="type == 2">
+                and a.start_time &lt; now() and end_time > now()
+            </if>
+            <if test="type == 3">
+                and a.end_time &lt; now()
+            </if>
+            <if test="id != null and id != 0">
+                and a.id = #{id}
+            </if>
+        </where>
+        ORDER BY a.id DESC
+    </select>
+
 </mapper>
 </mapper>

+ 11 - 0
fiveep-service/src/main/java/com/bizmatics/service/WcBlackoutPlanService.java

@@ -2,6 +2,10 @@ package com.bizmatics.service;
 
 
 import com.bizmatics.model.WcBlackoutPlan;
 import com.bizmatics.model.WcBlackoutPlan;
 import com.bizmatics.common.mvc.base.CrudService;
 import com.bizmatics.common.mvc.base.CrudService;
+import com.bizmatics.model.vo.WcBlackoutPlanVo;
+
+import java.util.Date;
+import java.util.List;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -13,4 +17,11 @@ import com.bizmatics.common.mvc.base.CrudService;
  */
  */
 public interface WcBlackoutPlanService extends CrudService<WcBlackoutPlan> {
 public interface WcBlackoutPlanService extends CrudService<WcBlackoutPlan> {
 
 
+    void plannedOutageAdd(WcBlackoutPlan wcBlackoutPlan);
+
+    void plannedOutageUpdate(WcBlackoutPlan wcBlackoutPlan);
+
+    void plannedOutageDel(int id);
+
+    List<WcBlackoutPlanVo> plannedOutageList(String startTime , String endTime , int type,int id);
 }
 }

+ 5 - 4
fiveep-service/src/main/java/com/bizmatics/service/impl/PlatformAreaServiceImpl.java

@@ -1,16 +1,17 @@
 package com.bizmatics.service.impl;
 package com.bizmatics.service.impl;
 
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.bizmatics.common.core.bean.CommonPage;
-import com.bizmatics.model.*;
+import com.bizmatics.common.mvc.base.AbstractCrudService;
+import com.bizmatics.model.Device;
+import com.bizmatics.model.DeviceAttribute;
+import com.bizmatics.model.PlatformArea;
+import com.bizmatics.model.Site;
 import com.bizmatics.model.vo.DeviceVo;
 import com.bizmatics.model.vo.DeviceVo;
 import com.bizmatics.model.vo.PlatformAreaVo;
 import com.bizmatics.model.vo.PlatformAreaVo;
 import com.bizmatics.model.vo.SiteDeviceList;
 import com.bizmatics.model.vo.SiteDeviceList;
 import com.bizmatics.persistence.mapper.PlatformAreaMapper;
 import com.bizmatics.persistence.mapper.PlatformAreaMapper;
 import com.bizmatics.service.PlatformAreaService;
 import com.bizmatics.service.PlatformAreaService;
-import com.bizmatics.common.mvc.base.AbstractCrudService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 

+ 34 - 0
fiveep-service/src/main/java/com/bizmatics/service/impl/WcBlackoutPlanServiceImpl.java

@@ -1,11 +1,18 @@
 package com.bizmatics.service.impl;
 package com.bizmatics.service.impl;
 
 
 import com.bizmatics.model.WcBlackoutPlan;
 import com.bizmatics.model.WcBlackoutPlan;
+import com.bizmatics.model.system.SysUser;
+import com.bizmatics.model.vo.WcBlackoutPlanVo;
 import com.bizmatics.persistence.mapper.WcBlackoutPlanMapper;
 import com.bizmatics.persistence.mapper.WcBlackoutPlanMapper;
 import com.bizmatics.service.WcBlackoutPlanService;
 import com.bizmatics.service.WcBlackoutPlanService;
 import com.bizmatics.common.mvc.base.AbstractCrudService;
 import com.bizmatics.common.mvc.base.AbstractCrudService;
+import com.bizmatics.service.util.SecurityUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
+import java.time.LocalDateTime;
+import java.util.Date;
+import java.util.List;
+
 /**
 /**
  * <p>
  * <p>
  *  服务实现类
  *  服务实现类
@@ -17,4 +24,31 @@ import org.springframework.stereotype.Service;
 @Service
 @Service
 public class WcBlackoutPlanServiceImpl extends AbstractCrudService<WcBlackoutPlanMapper, WcBlackoutPlan> implements WcBlackoutPlanService {
 public class WcBlackoutPlanServiceImpl extends AbstractCrudService<WcBlackoutPlanMapper, WcBlackoutPlan> implements WcBlackoutPlanService {
 
 
+    @Override
+    public void plannedOutageAdd(WcBlackoutPlan wcBlackoutPlan){
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        wcBlackoutPlan.setEnable(1);
+        wcBlackoutPlan.setCreator(user.getUserName());
+        wcBlackoutPlan.setCreateTime(LocalDateTime.now());
+        this.save(wcBlackoutPlan);
+    }
+
+    @Override
+    public void plannedOutageUpdate(WcBlackoutPlan wcBlackoutPlan){
+        this.updateById(wcBlackoutPlan);
+    }
+
+    @Override
+    public void plannedOutageDel(int id){
+        WcBlackoutPlan wcBlackoutPlan = new WcBlackoutPlan();
+        wcBlackoutPlan.setId(id);
+        wcBlackoutPlan.setEnable(0);
+        this.updateById(wcBlackoutPlan);
+    }
+
+    @Override
+    public List<WcBlackoutPlanVo> plannedOutageList(String startTime , String endTime , int type,int id){
+        List <WcBlackoutPlanVo> plannedOutageList = baseMapper.plannedOutageList(startTime,endTime,type,id);
+        return plannedOutageList;
+    }
 }
 }