2 Commits 8b9ddcad07 ... c77ff5243f

Author SHA1 Message Date
  xiruipeng c77ff5243f Merge remote-tracking branch 'origin/master' 2 years ago
  xiruipeng e0aebedcbd xrp-mybatis-wrapper计划电量增删改查 2 years ago

+ 0 - 1
web/backmanagerconfig/pom.xml

@@ -53,7 +53,6 @@
             <groupId>cn.hutool</groupId>
             <artifactId>hutool-all</artifactId>
             <version>5.1.1</version>
-            <scope>compile</scope>
         </dependency>
     </dependencies>
     <build>

+ 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();
 

+ 1 - 2
web/backmanagerconfig/src/main/java/com/gyee/backconfig/controller/ProjectController.java

@@ -10,12 +10,11 @@ import org.springframework.web.bind.annotation.RestController;
  *  前端控制器
  * </p>
  *
- * @author wang
+ * @author 郗瑞鹏
  * @since 2022-09-19
  */
 @RestController
 @RequestMapping("//project")
 public class ProjectController {
 
-
 }

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


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

@@ -26,7 +26,7 @@ public interface XrpProjectplanMapper extends BaseMapper<XrpProjectplan> {
      * @param: [id]
      * @return: java.util.Map<java.lang.String,java.lang.Object>
      **/
-    Map<String,Object> selectMapById(String id);
+    Map<String,Object> selectMapById(Long id);
 
     /**
      * @description:
@@ -36,5 +36,5 @@ public interface XrpProjectplanMapper extends BaseMapper<XrpProjectplan> {
      * @param :id
      * @return:
      **/
-    Page<XrpProjectplan> selectPageVo(@Param("page") Page<XrpProjectplan> page,@Param("id") String id);
+    Page<XrpProjectplan> selectPageVo(@Param("page") Page<XrpProjectplan> page,@Param("id") Long id);
 }

+ 86 - 38
web/backmanagerconfig/src/main/java/com/gyee/backconfig/service/BackConfigService.java

@@ -3,13 +3,13 @@ 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.backconfig.vo.Projectplanvo;
+import com.gyee.common.model.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.Currency;
 import java.util.List;
 
 /**
@@ -27,18 +27,17 @@ public class BackConfigService {
      * @param
      * @return
      */
-    //返回总查询
-    public List<XrpProjectplan> backConfigList() {
+    public List<XrpProjectplan> backConfigList(){
         List<XrpProjectplan> xrpProjectplanList = xrpProjectplanService.list();
 
         return xrpProjectplanList;
     }
 
     //根据id返回
-    public XrpProjectplan projectplanById(String 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;
     }
 
@@ -47,6 +46,7 @@ public class BackConfigService {
     }
 
 
+
     public Boolean saveSingle(XrpProjectplan xrpProjectplan) {
         return xrpProjectplanService.saveOrUpdate(xrpProjectplan);
     }
@@ -57,45 +57,93 @@ public class BackConfigService {
     //增加
 
     //分页查询
-    public  Page<XrpProjectplan> Page(Projectplanvo projectplanvo) {
-        Page<XrpProjectplan> Bypage = new Page<XrpProjectplan>(projectplanvo.getCurrent(), projectplanvo.getPagesize());
-        QueryWrapper<XrpProjectplan> queryWrapper=new QueryWrapper<XrpProjectplan>();
-
-        String id = projectplanvo.getId();
-        if (id.isEmpty()&id==null)
-        queryWrapper.eq("id",projectplanvo.getId());
 
-        String projectid = projectplanvo.getProjectid();
-        if (projectid.isEmpty()&projectid==null)
-        queryWrapper.eq("id",projectplanvo.getProjectid());
-
-        String generatingcapacity = projectplanvo.getGeneratingcapacity();
-        if (generatingcapacity.isEmpty()&generatingcapacity==null)
-        queryWrapper.eq("id",projectplanvo.getGeneratingcapacity());
-
-        String month = projectplanvo.getMonth();
-        if (month.isEmpty()&month==null)
-        queryWrapper.eq("id",projectplanvo.getMonth());
+    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;
+    }
 
-        String year = projectplanvo.getYear();
-        if (year.isEmpty()&year==null)
-        queryWrapper.eq("id",projectplanvo.getYear());
 
-        Double outagehours = projectplanvo.getOutagehours();
-        if (outagehours.isNaN()&outagehours==null)
-        queryWrapper.eq("id",projectplanvo.getOutagehours());
+    public boolean saveOrUpdate(XrpProjectplan xrpProjectplan) {
+        return xrpProjectplanService.saveOrUpdate(xrpProjectplan);
+    }
 
-        String windpower = projectplanvo.getWindpower();
-        if (windpower.isEmpty()&windpower==null)
-        queryWrapper.eq("id",projectplanvo.getWindpower());
-        queryWrapper.eq("id",projectplanvo.getIsdeleted());
-        queryWrapper.eq("id",projectplanvo.getCurrent());
-        queryWrapper.eq("id",projectplanvo.getPagesize());
+    public boolean removeWapper(XrpProjectplan xrpProjectplan) {
 
-        Page<XrpProjectplan> page = xrpProjectplanService.page(Bypage, queryWrapper);
 
-        return page;
+        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);
+    }
 }

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

@@ -8,7 +8,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
  *  服务类
  * </p>
  *
- * @author wang
+ * @author 郗瑞鹏
  * @since 2022-09-19
  */
 public interface IProjectService extends IService<Project> {

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

@@ -11,7 +11,7 @@ import org.springframework.stereotype.Service;
  *  服务实现类
  * </p>
  *
- * @author wang
+ * @author 郗瑞鹏
  * @since 2022-09-19
  */
 @Service

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

@@ -30,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;
+    }
+*/
     //根据条件查询
 
     //新增

+ 10 - 4
web/backmanagerconfig/src/main/resources/application-jn.yml

@@ -3,7 +3,6 @@ server:
   servlet:
     context-path: /
 
-
 spring:
   application:
     name: back-config
@@ -45,8 +44,8 @@ spring:
     type: com.alibaba.druid.pool.DruidDataSource
     driver-class-name: org.postgresql.Driver
     url: jdbc:postgresql://10.81.3.151:5432/wisdom
-    username: gdprod
-    password: gd123
+    username: postgres
+    password: postgres
     oracle-schema=:
     #    type: com.alibaba.druid.pool.DruidDataSource
     #    url: jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf8&serverTimezone=UTC
@@ -79,15 +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

+ 12 - 19
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.*;
 
 /**
@@ -39,12 +35,11 @@ public class BackConfigMainTests<test> {
         xrpProjectplanList.forEach(System.out::println);
     }
 
-//    插入一行
     @Test
     public void testInsert(){
         ArrayList<XrpProjectplan> xrpProjectplans = new ArrayList<>();
         XrpProjectplan xrpProjectplan = new XrpProjectplan();
-        xrpProjectplan.setId(String.valueOf(100l));
+        //xrpProjectplan.setId(100L);
         xrpProjectplan.setProjectid("3");
         xrpProjectplan.setGeneratingcapacity("2.4");
         xrpProjectplan.setOutagehours(3.2);
@@ -72,14 +67,13 @@ public class BackConfigMainTests<test> {
         System.out.println("id"+xrpProjectplan.getId());
     }
 
-    //deletbyid-按照id进行删除
+    //deletbyid
     @Test
     public void testDelete(){
-        int result = xrpProjectplanMapper.deleteById(1);
+        int result = xrpProjectplanMapper.deleteById("e5a142ea24686a3263590b43c08bb67d");
         System.out.println("result"+result);
     }
 
-
     @Test
     public void testByMap(){
         Map<String,Object> map=new HashMap<>();
@@ -93,7 +87,7 @@ public class BackConfigMainTests<test> {
 
     @Test
     public void testByDeleteBatch(){
-        List<String> longs = Arrays.asList("f21682be7be3191100926f994f89c7de", "45602bfc1ff27b11517f149981a0c4df");
+        List<String> longs = Arrays.asList("f21682be7be3191100926f994f89c7de", "597be69f450213db6d2b9e5c4c3b377f");
         int result = xrpProjectplanMapper.deleteBatchIds(longs);
         System.out.println("result:"+result);
 
@@ -103,9 +97,8 @@ public class BackConfigMainTests<test> {
     @Test
     public void testUpate(){
         XrpProjectplan xrpProjectplan = new XrpProjectplan();
-//        xrpProjectplan.setId(String.valueOf(1570251306048020483l));
-//        xrpProjectplan.setId("1233344");
-//        xrpProjectplan.setProjectid("3");
+      //  xrpProjectplan.setId(1570251306048020483L);
+        xrpProjectplan.setProjectid("3");
         xrpProjectplan.setGeneratingcapacity("2.4");
         xrpProjectplan.setOutagehours(3.2);
         xrpProjectplan.setYear("4");
@@ -114,16 +107,16 @@ public class BackConfigMainTests<test> {
         int result = xrpProjectplanMapper.updateById(xrpProjectplan);
     }
 
-//批量查询
     @Test
     public void testSelect(){
         /*XrpProjectplan xrpProjectplan = xrpProjectplanMapper.selectById(1570251304856838146L);
         System.out.println(xrpProjectplan);*/
-        List<String > String = Arrays.asList("f21682be7be3191100926f994f89c7de", "597be69f450213db6d2b9e5c4c3b377f", "d71feaac476bdf52da6714f6607afec7");
-        List<XrpProjectplan> xrpProjectplanList = xrpProjectplanMapper.selectBatchIds(String);
+        List<Long> longs = Arrays.asList(1570251304856838145L, 1570251304856838146L, 1570250808607682562L);
+        List<XrpProjectplan> xrpProjectplanList = xrpProjectplanMapper.selectBatchIds(longs);
         xrpProjectplanList.forEach(System.out::println);
-        Map<String, Object> map = new HashMap<>();
-//        map.put("id",1570250808607682562L);
+        Map<String
+                , Object> map = new HashMap<>();
+        map.put("id",1570250808607682562L);
         map.put("projectid","40");
         List<XrpProjectplan> xrpProjectplanList1 = xrpProjectplanMapper.selectByMap(map);
         xrpProjectplanList1.forEach(System.out::println);
@@ -131,7 +124,7 @@ public class BackConfigMainTests<test> {
 
     @Test
     public void testMapperXml(){
-        Map<String, Object> map = xrpProjectplanMapper.selectMapById("597be69f450213db6d2b9e5c4c3b377f");
+        Map<String, Object> map = xrpProjectplanMapper.selectMapById(1570251303959257090L);
         System.out.println(map);
     }
 }

+ 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("100");
+           // xrpProjectplan.setId(100L);
             xrpProjectplan.setProjectid("3");
             xrpProjectplan.setGeneratingcapacity("2.4");
             xrpProjectplan.setOutagehours(3.2);

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

@@ -10,9 +10,8 @@ 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 com.sun.org.apache.bcel.internal.generic.IFNE;
-import net.minidev.json.writer.UpdaterMapper;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -36,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
@@ -69,6 +76,7 @@ public class MyBatisPlusWrapperTest {
         System.out.println("result"+ delete);
     }
 
+
     //update biao set zd="" where month='' and  id or year
     @Test
     public void testUpdate2(){

+ 1 - 1
web/backmanagerconfig/src/test/java/MybatisPlusPluginsTest.java

@@ -42,7 +42,7 @@ public class MybatisPlusPluginsTest {
     @Test
     public void testPage2(){
         Page<XrpProjectplan> page=new Page<XrpProjectplan>(8,3);
-        xrpProjectplanMapper.selectPageVo(page,"f21682be7be3191100926f994f89c7de");
+        xrpProjectplanMapper.selectPageVo(page,1570249734874312705L);
         System.out.println(page.getRecords());
         System.out.println(page.getSize());
         System.out.println(page.getPages());