Browse Source

xrp-mybatis-wrapper计划电量增删改查

xiruipeng 2 years ago
parent
commit
e0aebedcbd
20 changed files with 611 additions and 32 deletions
  1. 5 0
      web/backmanagerconfig/pom.xml
  2. 38 0
      web/backmanagerconfig/src/main/java/com/gyee/backconfig/common/requst/vo/ProjectPlanQueryVo.java
  3. 1 0
      web/backmanagerconfig/src/main/java/com/gyee/backconfig/config/GeneratorCodeConfig.java
  4. 40 0
      web/backmanagerconfig/src/main/java/com/gyee/backconfig/config/MybatisPlusConfig.java
  5. 5 0
      web/backmanagerconfig/src/main/java/com/gyee/backconfig/config/Status.java
  6. 27 0
      web/backmanagerconfig/src/main/java/com/gyee/backconfig/config/ZTEnum.java
  7. 20 0
      web/backmanagerconfig/src/main/java/com/gyee/backconfig/controller/ProjectController.java
  8. 133 4
      web/backmanagerconfig/src/main/java/com/gyee/backconfig/controller/test/XrpProjectplanServiceController.java
  9. 12 0
      web/backmanagerconfig/src/main/java/com/gyee/backconfig/mapper/auto/XrpProjectplanMapper.java
  10. 10 3
      web/backmanagerconfig/src/main/java/com/gyee/backconfig/model/auto/XrpProjectplan.java
  11. 88 2
      web/backmanagerconfig/src/main/java/com/gyee/backconfig/service/BackConfigService.java
  12. 16 0
      web/backmanagerconfig/src/main/java/com/gyee/backconfig/service/auto/IProjectService.java
  13. 20 0
      web/backmanagerconfig/src/main/java/com/gyee/backconfig/service/auto/impl/ProjectServiceImpl.java
  14. 8 0
      web/backmanagerconfig/src/main/java/com/gyee/backconfig/service/auto/impl/XrpProjectplanServiceImpl.java
  15. 7 2
      web/backmanagerconfig/src/main/resources/application-jn.yml
  16. 1 1
      web/backmanagerconfig/src/main/resources/application.yml
  17. 4 8
      web/backmanagerconfig/src/test/java/BackConfigMainTests.java
  18. 1 2
      web/backmanagerconfig/src/test/java/MyBatisPlusServiceTest.java
  19. 82 10
      web/backmanagerconfig/src/test/java/MyBatisPlusWrapperTest.java
  20. 93 0
      web/backmanagerconfig/src/test/java/MybatisPlusPluginsTest.java

+ 5 - 0
web/backmanagerconfig/pom.xml

@@ -49,6 +49,11 @@
             <groupId>org.postgresql</groupId>
             <artifactId>postgresql</artifactId>
         </dependency>
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.1.1</version>
+        </dependency>
     </dependencies>
     <build>
         <plugins>

+ 38 - 0
web/backmanagerconfig/src/main/java/com/gyee/backconfig/common/requst/vo/ProjectPlanQueryVo.java

@@ -0,0 +1,38 @@
+package com.gyee.backconfig.common.requst.vo;/**
+ * @author 50560
+ * @create 2022-09-19 15:55
+ */
+
+import lombok.Data;
+
+/**
+ * @BelongsProject: workpathnew
+ * @BelongsPackage: com.gyee.backconfig.common.requst.vo
+ * @Author: xiruipeng
+ * @CreateTime: 2022-09-19  15:55
+ * @Description: TODO
+ * @Version: 1.0
+ */
+@Data
+public class ProjectPlanQueryVo {
+    private String id;
+
+    private String projectid;
+
+    private String generatingcapacity;
+
+    private Double outagehours;
+
+    private String year;
+
+    private String month;
+
+    private String windpower;
+
+    private Integer version;
+    //分页
+    private Integer current;
+    private Integer pageSize;
+
+
+}

+ 1 - 0
web/backmanagerconfig/src/main/java/com/gyee/backconfig/config/GeneratorCodeConfig.java

@@ -33,6 +33,7 @@ public class GeneratorCodeConfig {
     }
 
     public static void main(String[] args) {
+        System.out.println("jjjjjjjjjj");
         // 代码生成器
         AutoGenerator mpg = new AutoGenerator();
 

+ 40 - 0
web/backmanagerconfig/src/main/java/com/gyee/backconfig/config/MybatisPlusConfig.java

@@ -1,9 +1,17 @@
 package com.gyee.backconfig.config;
 
+
+import cn.hutool.core.date.DatePattern;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.IdUtil;
+import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
+import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
 import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
+import java.util.Date;
+
 /**
  *@ClassName MybatisPlusConfig
  *@Description 配置分页插件
@@ -20,4 +28,36 @@ public class MybatisPlusConfig {
     public PaginationInterceptor paginationInterceptor() {
         return new PaginationInterceptor();
     }
+
+    /**
+     * @description:
+     * @author: xiruipeng 
+     * @date: 2022/9/16 15:08
+     * @param: []
+     * @return: com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor
+     **/
+    @Bean
+    public OptimisticLockerInterceptor optimisticLockerInterceptor(){
+        return new OptimisticLockerInterceptor();
+    }
+
+
+    /**
+     * 自定义主键生成:生成的 当前时间 + 随机数的格式
+     * @return
+     */
+    @Bean
+    public IdentifierGenerator idGenerator() {
+        return new IdentifierGenerator() {
+            @Override
+            public Number nextId(Object entity) {
+                return null;
+            }
+
+            @Override
+            public String nextUUID(Object entity) {
+                return DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN)+ IdUtil.simpleUUID();
+            }
+        };
+    }
 }

+ 5 - 0
web/backmanagerconfig/src/main/java/com/gyee/backconfig/config/Status.java

@@ -18,6 +18,8 @@ public enum Status {
     WARN(9000, "失败"),
     REQUEST_PARAMETER_ERROR(1002, "请求参数错误"),
 
+
+
     // 登录
     LOGIN_EXPIRE(2001, "未登录或者登录失效"),
     LOGIN_CODE_ERROR(2002, "登录验证码错误"),
@@ -27,6 +29,9 @@ public enum Status {
     LOGIN_USER_NOT_EXIST(2006, "该用户不存在"),
     LOGIN_USER_EXIST(2007, "该用户已存在");
 
+
+
+
     public int code;
     public String message;
 

+ 27 - 0
web/backmanagerconfig/src/main/java/com/gyee/backconfig/config/ZTEnum.java

@@ -0,0 +1,27 @@
+package com.gyee.backconfig.config;
+
+import com.baomidou.mybatisplus.annotation.EnumValue;
+import com.fasterxml.jackson.annotation.JsonValue;
+import lombok.Getter;
+
+/**
+ * @author 50560
+ * @create 2022-09-16 15:39
+ */
+@Getter
+public enum ZTEnum {
+
+    //遥信
+    K(1, "开"),
+    G(0,"关");
+
+    @EnumValue
+    public Integer code;
+    @JsonValue
+    public String message;
+
+    ZTEnum(int code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+}

+ 20 - 0
web/backmanagerconfig/src/main/java/com/gyee/backconfig/controller/ProjectController.java

@@ -0,0 +1,20 @@
+package com.gyee.backconfig.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author 郗瑞鹏
+ * @since 2022-09-19
+ */
+@RestController
+@RequestMapping("//project")
+public class ProjectController {
+
+}

File diff suppressed because it is too large
+ 133 - 4
web/backmanagerconfig/src/main/java/com/gyee/backconfig/controller/test/XrpProjectplanServiceController.java


+ 12 - 0
web/backmanagerconfig/src/main/java/com/gyee/backconfig/mapper/auto/XrpProjectplanMapper.java

@@ -1,7 +1,9 @@
 package com.gyee.backconfig.mapper.auto;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gyee.backconfig.model.auto.XrpProjectplan;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 import java.util.Map;
@@ -25,4 +27,14 @@ public interface XrpProjectplanMapper extends BaseMapper<XrpProjectplan> {
      * @return: java.util.Map<java.lang.String,java.lang.Object>
      **/
     Map<String,Object> selectMapById(Long id);
+
+    /**
+     * @description:
+     * @author: xiruipeng
+     * @date: 2022/9/16 11:25
+     * @param: Page mybatis-plust提供,必须在第一个
+     * @param :id
+     * @return:
+     **/
+    Page<XrpProjectplan> selectPageVo(@Param("page") Page<XrpProjectplan> page,@Param("id") Long id);
 }

+ 10 - 3
web/backmanagerconfig/src/main/java/com/gyee/backconfig/model/auto/XrpProjectplan.java

@@ -1,9 +1,9 @@
 package com.gyee.backconfig.model.auto;
 
-import java.math.BigDecimal;
 
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.gyee.backconfig.config.ZTEnum;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
@@ -21,10 +21,11 @@ import lombok.EqualsAndHashCode;
 public class XrpProjectplan extends Model {
 
     private static final long serialVersionUID = 1L;
-    @TableId(value="ID",type = IdType.ASSIGN_ID)//指定自增策略
+   // @TableId(value="ID",type = IdType.ASSIGN_ID)//指定自增策略
     // bigint,int8表里面是,默认 只能使用id作为主键,@tableId 将属性对应的字段作为指定主键
     //value="ID" 这里id和数据库中指定作为主键的字段,value=可以省略;
-    private Long id;
+    @TableId(value="ID")
+    private String id;
 
     @TableField("PROJECTID")
     private String projectid;
@@ -50,4 +51,10 @@ public class XrpProjectplan extends Model {
     @TableLogic
     private Integer isdeleted;
 
+    @Version
+    @TableField("VERSION")
+    private Integer version;
+
+    private ZTEnum zt;
+
 }

+ 88 - 2
web/backmanagerconfig/src/main/java/com/gyee/backconfig/service/BackConfigService.java

@@ -2,13 +2,15 @@ package com.gyee.backconfig.service;
 
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gyee.backconfig.common.requst.vo.ProjectPlanQueryVo;
 import com.gyee.backconfig.model.auto.XrpProjectplan;
 import com.gyee.backconfig.service.auto.IXrpProjectplanService;
+import com.gyee.common.model.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.List;
-import java.util.Map;
 
 /**
  * @author 50560
@@ -34,8 +36,8 @@ public class BackConfigService {
     //根据id返回
     public XrpProjectplan projectplanById(String id){
         QueryWrapper<XrpProjectplan> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("id",id);
         XrpProjectplan xrpProjectplan = xrpProjectplanService.getOne(queryWrapper);
+        queryWrapper.eq("id",id);
         return xrpProjectplan;
     }
 
@@ -54,10 +56,94 @@ public class BackConfigService {
 
     //增加
 
+    //分页查询
+
+    public Page<XrpProjectplan> listBypage(ProjectPlanQueryVo vo){
+        Page<XrpProjectplan> page=new Page<XrpProjectplan>(vo.getCurrent(),vo.getPageSize());
+
+        QueryWrapper<XrpProjectplan> queryWrapper=new QueryWrapper<>();
+         String id=vo.getId();;
+         String projectid=vo.getProjectid();
+         String generatingcapacity=vo.getGeneratingcapacity();
+         Double outagehours=vo.getOutagehours();
+         String year=vo.getYear();
+         String month=vo.getMonth();
+         String windpower=vo.getWindpower();
+
+
+        if(StringUtils.isNotNull(id)&&!id.equals("")){
+            queryWrapper.eq("id",id);
+        }
+        if (StringUtils.isNotNull(projectid)&&!projectid.equals("")){
+            queryWrapper.eq("projectid",projectid);
+        }
+        if (StringUtils.isNotNull(generatingcapacity)&&!generatingcapacity.equals("")){
+            queryWrapper.eq("generatingcapacity",generatingcapacity);
+        }
+        if (StringUtils.isNotNull(outagehours)&&outagehours!=0.0){
+            queryWrapper.eq("outagehours",outagehours);
+        }
+        if (StringUtils.isNotNull(year)&&!year.equals("")){
+            queryWrapper.eq("year",year);
+        }
+        if (StringUtils.isNotNull(month)&&!month.equals("")){
+            queryWrapper.eq("month",month);
+        }
+        if (StringUtils.isNotNull(windpower)&&!windpower.equals("")){
+            queryWrapper.eq("windpower",windpower);
+        }
+
+        Page<XrpProjectplan> page1 = xrpProjectplanService.page(page, queryWrapper);
+        return page1;
+    }
 
 
+    public boolean saveOrUpdate(XrpProjectplan xrpProjectplan) {
+        return xrpProjectplanService.saveOrUpdate(xrpProjectplan);
+    }
+
+    public boolean removeWapper(XrpProjectplan xrpProjectplan) {
 
 
+        QueryWrapper<XrpProjectplan> queryWrapper=new QueryWrapper<XrpProjectplan>();
+        conditionJudge(xrpProjectplan, queryWrapper);
+        return xrpProjectplanService.remove(queryWrapper);
+    }
 
+    private void conditionJudge(XrpProjectplan xrpProjectplan, QueryWrapper<XrpProjectplan> queryWrapper) {
+        String id=xrpProjectplan.getId();
+        String projectid=xrpProjectplan.getProjectid();
+        String generatingcapacity=xrpProjectplan.getGeneratingcapacity();
+        Double outagehours=xrpProjectplan.getOutagehours();
+        String year=xrpProjectplan.getYear();
+        String month=xrpProjectplan.getMonth();
+        String windpower=xrpProjectplan.getWindpower();
+        if(StringUtils.isNotNull(id)&&!id.equals("")){
+            queryWrapper.eq("id",id);
+        }
+        if (StringUtils.isNotNull(projectid)&&!projectid.equals("")){
+            queryWrapper.eq("projectid",projectid);
+        }
+        if (StringUtils.isNotNull(generatingcapacity)&&!generatingcapacity.equals("")){
+            queryWrapper.eq("generatingcapacity",generatingcapacity);
+        }
+        if (StringUtils.isNotNull(outagehours)&&outagehours!=0.0){
+            queryWrapper.eq("outagehours",outagehours);
+        }
+        if (StringUtils.isNotNull(year)&&!year.equals("")){
+            queryWrapper.eq("year",year);
+        }
+        if (StringUtils.isNotNull(month)&&!month.equals("")){
+            queryWrapper.eq("month",month);
+        }
+        if (StringUtils.isNotNull(windpower)&&!windpower.equals("")){
+            queryWrapper.eq("windpower",windpower);
+        }
+    }
 
+    public boolean removeWapperById(String id) {
+        QueryWrapper<XrpProjectplan> queryWrapper=new QueryWrapper<XrpProjectplan>();
+        queryWrapper.eq("id",id);
+        return xrpProjectplanService.remove(queryWrapper);
+    }
 }

+ 16 - 0
web/backmanagerconfig/src/main/java/com/gyee/backconfig/service/auto/IProjectService.java

@@ -0,0 +1,16 @@
+package com.gyee.backconfig.service.auto;
+
+import com.gyee.backconfig.model.auto.Project;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 郗瑞鹏
+ * @since 2022-09-19
+ */
+public interface IProjectService extends IService<Project> {
+
+}

+ 20 - 0
web/backmanagerconfig/src/main/java/com/gyee/backconfig/service/auto/impl/ProjectServiceImpl.java

@@ -0,0 +1,20 @@
+package com.gyee.backconfig.service.auto.impl;
+
+import com.gyee.backconfig.model.auto.Project;
+import com.gyee.backconfig.mapper.auto.ProjectMapper;
+import com.gyee.backconfig.service.auto.IProjectService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 郗瑞鹏
+ * @since 2022-09-19
+ */
+@Service
+public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements IProjectService {
+
+}

+ 8 - 0
web/backmanagerconfig/src/main/java/com/gyee/backconfig/service/auto/impl/XrpProjectplanServiceImpl.java

@@ -1,5 +1,6 @@
 package com.gyee.backconfig.service.auto.impl;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gyee.backconfig.model.auto.XrpProjectplan;
 import com.gyee.backconfig.mapper.auto.XrpProjectplanMapper;
 import com.gyee.backconfig.service.auto.IXrpProjectplanService;
@@ -29,6 +30,13 @@ public class XrpProjectplanServiceImpl extends ServiceImpl<XrpProjectplanMapper,
         return xrpProjectplanMapper.selectList(null);
     }
 
+    //不加条件的分页
+    /*public Page<XrpProjectplan> queryByPage(int current,int pagesize){
+        Page<XrpProjectplan> page=new Page<XrpProjectplan>(1,3);
+        Page<XrpProjectplan> xrpProjectplanPage = xrpProjectplanMapper.selectPage(page, null);
+        return xrpProjectplanPage;
+    }
+*/
     //根据条件查询
 
     //新增

+ 7 - 2
web/backmanagerconfig/src/main/resources/application-jn.yml

@@ -3,7 +3,6 @@ server:
   servlet:
     context-path: /
 
-
 spring:
   application:
     name: back-config
@@ -79,16 +78,22 @@ mybatis-plus:
     map-underscore-to-camel-case: true
     auto-mapping-behavior: full
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    default-enum-type-handler: org.apache.ibatis.type.EnumOrdinalTypeHandler
   mapper-locations: classpath*:mapper/**/*Mapper.xml
   global-config:
     # 逻辑删除配置
     db-config:
-      id-type: auto
+      #id-type: auto
       # 删除前
       logic-not-delete-value: 1
       # 删除后
       logic-delete-value: 0
       #table-prefix: t_
+      id-type: assign_uuid
+  #配置类型别名对应的包
+  type-aliases-package: com.gyee.backconfig.model.auto
+  #用于扫描通用枚举包
+  type-enums-package: com.gyee.backconfig.config
 logging:
   level:
     root: info

+ 1 - 1
web/backmanagerconfig/src/main/resources/application.yml

@@ -1,4 +1,4 @@
 spring:
   profiles:
     active: jn
-#    active: test
+#    active: test

+ 4 - 8
web/backmanagerconfig/src/test/java/BackConfigMainTests.java

@@ -3,19 +3,15 @@
  * @create 2022-09-15 9:53
  */
 
-import com.alibaba.fastjson.JSONArray;
 import com.gyee.backconfig.BackConfigMain;
 import com.gyee.backconfig.mapper.auto.XrpProjectplanMapper;
 import com.gyee.backconfig.model.auto.XrpProjectplan;
-import org.apache.commons.math3.analysis.integration.IterativeLegendreGaussIntegrator;
 import org.junit.Test;
-import org.junit.runner.Result;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
-import javax.xml.bind.SchemaOutputResolver;
 import java.util.*;
 
 /**
@@ -43,7 +39,7 @@ public class BackConfigMainTests<test> {
     public void testInsert(){
         ArrayList<XrpProjectplan> xrpProjectplans = new ArrayList<>();
         XrpProjectplan xrpProjectplan = new XrpProjectplan();
-        xrpProjectplan.setId(100L);
+        //xrpProjectplan.setId(100L);
         xrpProjectplan.setProjectid("3");
         xrpProjectplan.setGeneratingcapacity("2.4");
         xrpProjectplan.setOutagehours(3.2);
@@ -74,7 +70,7 @@ public class BackConfigMainTests<test> {
     //deletbyid
     @Test
     public void testDelete(){
-        int result = xrpProjectplanMapper.deleteById(1);
+        int result = xrpProjectplanMapper.deleteById("e5a142ea24686a3263590b43c08bb67d");
         System.out.println("result"+result);
     }
 
@@ -91,7 +87,7 @@ public class BackConfigMainTests<test> {
 
     @Test
     public void testByDeleteBatch(){
-        List<Long> longs = Arrays.asList(2L, 1570249734874312705L, 1570251304856838146L);
+        List<String> longs = Arrays.asList("f21682be7be3191100926f994f89c7de", "597be69f450213db6d2b9e5c4c3b377f");
         int result = xrpProjectplanMapper.deleteBatchIds(longs);
         System.out.println("result:"+result);
 
@@ -101,7 +97,7 @@ public class BackConfigMainTests<test> {
     @Test
     public void testUpate(){
         XrpProjectplan xrpProjectplan = new XrpProjectplan();
-        xrpProjectplan.setId(1570251306048020483L);
+      //  xrpProjectplan.setId(1570251306048020483L);
         xrpProjectplan.setProjectid("3");
         xrpProjectplan.setGeneratingcapacity("2.4");
         xrpProjectplan.setOutagehours(3.2);

+ 1 - 2
web/backmanagerconfig/src/test/java/MyBatisPlusServiceTest.java

@@ -4,7 +4,6 @@
  */
 
 import com.gyee.backconfig.BackConfigMain;
-import com.gyee.backconfig.mapper.auto.XrpProjectplanMapper;
 import com.gyee.backconfig.model.auto.XrpProjectplan;
 import com.gyee.backconfig.service.auto.IXrpProjectplanService;
 import org.junit.Test;
@@ -60,7 +59,7 @@ public class MyBatisPlusServiceTest {
     public void testAdd(){
 
             XrpProjectplan xrpProjectplan= new XrpProjectplan();
-            xrpProjectplan.setId(100L);
+           // xrpProjectplan.setId(100L);
             xrpProjectplan.setProjectid("3");
             xrpProjectplan.setGeneratingcapacity("2.4");
             xrpProjectplan.setOutagehours(3.2);

+ 82 - 10
web/backmanagerconfig/src/test/java/MyBatisPlusWrapperTest.java

@@ -3,13 +3,15 @@
  * @create 2022-09-15 14:48
  */
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.gyee.backconfig.BackConfigMain;
 import com.gyee.backconfig.mapper.auto.XrpProjectplanMapper;
 import com.gyee.backconfig.model.auto.XrpProjectplan;
+import com.gyee.backconfig.service.auto.IXrpProjectplanService;
 import com.gyee.common.model.StringUtils;
-import net.minidev.json.writer.UpdaterMapper;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -33,6 +35,14 @@ public class MyBatisPlusWrapperTest {
     @Autowired
     private XrpProjectplanMapper xrpProjectplanMapper;
 
+    @Autowired
+    private IXrpProjectplanService xrpProjectplanService;
+    @Test
+    public void testRemove(){
+        QueryWrapper<XrpProjectplan> queryWrapper=new QueryWrapper<XrpProjectplan>();
+        queryWrapper.eq("id","ea87011f98c11dae924c73802ce1b4d8");
+        xrpProjectplanService.remove(queryWrapper);
+    }
     @Test
     public void testWrapper(){
         //==>  Preparing: SELECT ID,PROJECTID,GENERATINGCAPACITY,OUTAGEHOURS,YEAR,MONTH,WINDPOWER,isdeleted FROM XRP_PROJECTPLAN WHERE isdeleted=1
@@ -61,11 +71,12 @@ public class MyBatisPlusWrapperTest {
         //删除id
         QueryWrapper<XrpProjectplan> queryWrapper=new QueryWrapper<>();
         //queryWrapper.isNotNull("month");
-        queryWrapper.eq("month","");
+        queryWrapper.eq("GENERATINGCAPACITY","100.4");
         int delete = xrpProjectplanMapper.delete(queryWrapper);
         System.out.println("result"+ delete);
     }
 
+
     //update biao set zd="" where month='' and  id or year
     @Test
     public void testUpdate2(){
@@ -92,7 +103,7 @@ public class MyBatisPlusWrapperTest {
         //lambda中的条件优先执行
         //==>  Preparing: UPDATE XRP_PROJECTPLAN SET PROJECTID=?, GENERATINGCAPACITY=?
         // WHERE isdeleted=1 AND (month = ? AND (id > ? OR year LIKE ?))
-        QueryWrapper<XrpProjectplan> queryWrapper = new QueryWrapper<>();
+        UpdateWrapper<XrpProjectplan> queryWrapper = new UpdateWrapper<>();
         queryWrapper.eq("month","")
                 .and(
                         i->i.gt("id",1570251305913802753L)
@@ -109,13 +120,21 @@ public class MyBatisPlusWrapperTest {
         System.out.println("result:"+result);
     }
 
+    //函数式接口指定
     @Test
-    public void testPro(){
-        QueryWrapper<XrpProjectplan> queryWrapper=new QueryWrapper<>();
-        queryWrapper.select("ID","PROJECTID","YEAR");
-        //组装属性字段
-        List<Map<String, Object>> maps = xrpProjectplanMapper.selectMaps(queryWrapper);
-        maps.forEach(System.out::println);
+    public void testUpdatePerLambda(){
+        LambdaUpdateWrapper<XrpProjectplan> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.like(XrpProjectplan::getYear,"")
+                .gt(XrpProjectplan::getMonth,"5")
+                .and(
+                        i->i.gt(XrpProjectplan::getId,1570251306048020482L)
+                                .or()
+                                .like(XrpProjectplan::getYear,"49")
+                );
+        updateWrapper
+                .set(XrpProjectplan::getProjectid,"120").set(XrpProjectplan::getGeneratingcapacity,111.7);
+        int result = xrpProjectplanMapper.update(null, updateWrapper);
+        System.out.println("result:"+result);
     }
 
     @Test
@@ -130,10 +149,24 @@ public class MyBatisPlusWrapperTest {
         System.out.println("result:"+result);
     }
 
+
+    @Test
+    public void testPro(){
+        QueryWrapper<XrpProjectplan> queryWrapper=new QueryWrapper<>();
+        queryWrapper.select("ID","PROJECTID","YEAR","generatingcapacity");
+        //组装属性字段
+        List<Map<String, Object>> maps = xrpProjectplanMapper.selectMaps(queryWrapper);
+        maps.forEach(System.out::println);
+    }
+
+
+
+
+
     //组装条件
     @Test
     public void test(){
-       String year="";
+       String year="5";
        Long idBegin=1570251304856838145L;
        Long idEnd=1570284357834518534L;
        QueryWrapper<XrpProjectplan> queryWrapper=new QueryWrapper<>();
@@ -143,6 +176,45 @@ public class MyBatisPlusWrapperTest {
        }
 
        //if(idBegin)
+        if (idBegin == null) {
+            queryWrapper.ge("id",idBegin);
+        }
+        if (idEnd == null) {
+            queryWrapper.le("id",idEnd);
+        }
 
+        List<XrpProjectplan> list = xrpProjectplanMapper.selectList(queryWrapper);
+        list.forEach(System.out::println);
     }
+
+    //组装条件 Condition
+    @Test
+    public void testCondition(){
+        String year="5";
+        Long idBegin=1570251304856838145L;
+        Long idEnd=1570284357834518534L;
+        QueryWrapper<XrpProjectplan> queryWrapper=new QueryWrapper<>();
+        queryWrapper.like(StringUtils.isNotEmpty(year),"year",year)
+                .ge(idBegin!=null,"id",idBegin)
+                .le(idEnd!=null,"id",idEnd);
+        List<XrpProjectplan> xrpProjectplanList = xrpProjectplanMapper.selectList(queryWrapper);
+        xrpProjectplanList.forEach(System.out::println);
+    }
+
+    @Test
+    public void TestLambda(){
+        String year="5";
+        Long idBegin=1570251304856838145L;
+        Long idEnd=1570284357834518534L;
+        LambdaQueryWrapper<XrpProjectplan> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.like(StringUtils.isNotBlank(year),XrpProjectplan::getYear,year)
+        .ge(idBegin!=null,XrpProjectplan::getId,idBegin)
+                .le(idEnd!=null,XrpProjectplan::getId,idEnd);
+        List<XrpProjectplan> list = xrpProjectplanMapper.selectList(lambdaQueryWrapper);
+        list.forEach(System.out::println);
+    }
+
+
+
+
 }

+ 93 - 0
web/backmanagerconfig/src/test/java/MybatisPlusPluginsTest.java

@@ -0,0 +1,93 @@
+/**
+ * @author 50560
+ * @create 2022-09-16 11:04
+ */
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gyee.backconfig.BackConfigMain;
+import com.gyee.backconfig.config.ZTEnum;
+import com.gyee.backconfig.mapper.auto.XrpProjectplanMapper;
+import com.gyee.backconfig.model.auto.XrpProjectplan;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+/**
+ *@BelongsProject: workpathnew
+ *@BelongsPackage: PACKAGE_NAME
+ *@Author: xiruipeng
+ *@CreateTime: 2022-09-16  11:04
+ *@Description: TODO
+ *@Version: 1.0
+ */
+@SpringBootTest(classes = {BackConfigMain.class})
+@RunWith(SpringRunner.class)
+public class MybatisPlusPluginsTest {
+    @Autowired
+    private XrpProjectplanMapper xrpProjectplanMapper;
+
+    //分页插件
+    @Test
+    public void testPage(){
+        Page<XrpProjectplan> page=new Page<XrpProjectplan>(1,3);
+        xrpProjectplanMapper.selectPage(page,null);
+        System.out.println(page.getRecords());
+        System.out.println(page.getSize());
+        System.out.println(page.getPages());
+        System.out.println(page.getTotal());
+        System.out.println(page.hasPrevious());
+    }
+    //自定义分页插件
+    @Test
+    public void testPage2(){
+        Page<XrpProjectplan> page=new Page<XrpProjectplan>(8,3);
+        xrpProjectplanMapper.selectPageVo(page,1570249734874312705L);
+        System.out.println(page.getRecords());
+        System.out.println(page.getSize());
+        System.out.println(page.getPages());
+        System.out.println(page.getTotal());
+        System.out.println(page.hasPrevious());
+        System.out.println("有没下一页"+page.hasNext());
+    }
+
+    //乐观锁和悲观锁
+    @Test
+    public void testProduct01(){
+        //小李查询商品价格
+        XrpProjectplan projectplanLi = xrpProjectplanMapper.selectById(1570251303959257090L);
+        System.out.println("小李的查询年:"+projectplanLi.getOutagehours());
+        XrpProjectplan projectplanWang= xrpProjectplanMapper.selectById(1570251303959257090L);
+        System.out.println("小王查询的商品价格:"+projectplanWang.getOutagehours());
+        //小李将商品价格+50
+        projectplanLi.setOutagehours(projectplanLi.getOutagehours()+50);;
+        xrpProjectplanMapper.updateById(projectplanLi);
+        //小王将商品价格-30
+        projectplanWang.setOutagehours(projectplanWang.getOutagehours()-30);
+        int result = xrpProjectplanMapper.updateById(projectplanWang);
+        //判断是否更新成功,不成功需要重试
+        if(result==0){
+            XrpProjectplan projectplanNew=xrpProjectplanMapper.selectById(1570251303959257090L);
+            projectplanNew.setOutagehours(projectplanNew.getOutagehours()-30);
+            xrpProjectplanMapper.updateById(projectplanNew);
+        }
+        //老板查询的商品价格
+        XrpProjectplan projectplanBoss=xrpProjectplanMapper.selectById(1570251303959257090L);
+        System.out.println("老板查询的商品价格"+projectplanBoss.getOutagehours());
+    }
+
+    @Test
+    public void testEum(){
+        XrpProjectplan xrpProjectplan=new XrpProjectplan();
+        xrpProjectplan.setProjectid("1001");
+        xrpProjectplan.setGeneratingcapacity("2.4");
+        xrpProjectplan.setOutagehours(3.2);
+        xrpProjectplan.setYear("4");
+        xrpProjectplan.setMonth("6");
+        xrpProjectplan.setWindpower("22");
+        xrpProjectplan.setZt(ZTEnum.G);
+        int insert = xrpProjectplanMapper.insert(xrpProjectplan);
+        System.out.println("result:"+insert);
+
+    }
+}