ソースを参照

Merge remote-tracking branch 'origin/master'

zhuang 1 年間 前
コミット
f7cbff45c1

+ 4 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxItpProjectNodesService.java

@@ -2,7 +2,9 @@ package com.rongwei.bscommon.sys.service;
 
 import com.rongwei.bsentity.domain.ZhcxItpProjectNodesDo;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwei.bsentity.vo.CopyNodeVo;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -17,4 +19,6 @@ public interface ZhcxItpProjectNodesService extends IService<ZhcxItpProjectNodes
 
     void projectNodeQuote(Map<String,Object> map);
 
+    List<Map<String,Object>> copyProjectNode(CopyNodeVo copyNodeVo);
+
 }

+ 64 - 4
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxItpProjectNodesServiceImpl.java

@@ -6,16 +6,16 @@ import com.rongwei.bscommon.sys.service.*;
 import com.rongwei.bsentity.domain.*;
 import com.rongwei.bscommon.sys.dao.ZhcxItpProjectNodesDao;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwei.bsentity.vo.CopyNodeVo;
+import com.rongwei.commonservice.service.dao.CommonSqlDao;
 import com.rongwei.rwcommon.base.exception.CustomException;
 import com.rongwei.rwcommon.utils.SecurityUtil;
 import com.rongwei.rwcommon.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.math.BigDecimal;
+import java.util.*;
 
 /**
  * <p>
@@ -36,6 +36,8 @@ public class ZhcxItpProjectNodesServiceImpl extends ServiceImpl<ZhcxItpProjectNo
     private ZhcxItpProjectNodesFilesService zhcxItpProjectNodesFilesService;
     @Autowired
     private ZhcxProjectDeviceNumberService zhcxProjectDeviceNumberService;
+    @Autowired
+    private CommonSqlDao commonSqlDao;
 
     /**
      * 项目引用ITP模板节点
@@ -142,4 +144,62 @@ public class ZhcxItpProjectNodesServiceImpl extends ServiceImpl<ZhcxItpProjectNo
             throw new CustomException("项目ID不能为空");
         }
     }
+
+    /**
+     * 复制项目节点
+     * @param copyNodeVo
+     * @return
+     */
+    @Override
+    public List<Map<String, Object>> copyProjectNode(CopyNodeVo copyNodeVo) {
+        // 复制数据
+        if(StringUtils.isNotBlank(copyNodeVo.getCopysourceid()) && copyNodeVo.getCopytoid() != null){
+            List<ZhcxItpProjectNodesDo> toSave = new ArrayList<>();
+
+            List<String> toids = new ArrayList<>();
+            Map<String,String> idSort = new HashMap<>();
+            copyNodeVo.getCopytoid().forEach(v->{
+                if(v.containsKey("id")){
+                    toids.add(v.get("id").toString());
+                    if(v.containsKey("lastsort")){
+                        idSort.put(v.get("id").toString(),v.get("lastsort").toString());
+                    }
+                }
+            });
+            ZhcxItpProjectNodesDo sourceDo = this.getById(copyNodeVo.getCopysourceid());
+            List<ZhcxItpProjectNodesDo> toDos = (List<ZhcxItpProjectNodesDo>)this.listByIds(toids);
+            if(toDos != null && toDos.size()>0){
+                for (ZhcxItpProjectNodesDo toDo : toDos) {
+                    ZhcxItpProjectNodesDo newDo = new ZhcxItpProjectNodesDo();
+                    BeanUtil.copyProperties(sourceDo,newDo);
+                    newDo.setId(SecurityUtil.getUUID());
+                    if(idSort.containsKey(toDo.getId())){
+                        newDo.setSortindex(new BigDecimal(idSort.get(toDo.getId())));
+                    }else{
+                        newDo.setSortindex(new BigDecimal("0"));
+                    }
+                    newDo.setPid(toDo.getId());
+                    toSave.add(newDo);
+                }
+            }
+
+            if(toSave != null && toSave.size()>0){
+                this.saveBatch(toSave);
+            }
+        }
+
+        // 返回数据
+        return getProjectNodes(copyNodeVo);
+    }
+
+    /**
+     * 返回最新数据
+     * @param copyNodeVo
+     * @return
+     */
+    private List<Map<String, Object>> getProjectNodes(CopyNodeVo copyNodeVo){
+        String sql = "select * from ZHCX_ITP_PROJECT_NODES where PROJECTID='"+ copyNodeVo.getProjectid() +"' and deleted='0' order by sortindex asc";
+        List<Map<String, Object>> nodes = commonSqlDao.sqlExecutu(sql);
+        return nodes;
+    }
 }

+ 1 - 1
business-common/src/main/java/com/rongwei/bscommon/sys/utils/CodeGeneration.java

@@ -85,7 +85,7 @@ public class CodeGeneration {
         strategy.setSuperEntityClass(BaseDo.class);
         strategy.setRestControllerStyle(true);
         // 设置要映射的表名(重要,需要修改的地方)
-        strategy.setInclude("ZHCX_ITP_TEMPLATE","ZHCX_ITP_TEMPLATE_NODES");
+        strategy.setInclude("ZHCX_PROJECT_DEVICE_NUMBER");
         strategy.setNaming(NamingStrategy.underline_to_camel); // 自动转换表名的驼峰命名法
         strategy.setColumnNaming(NamingStrategy.no_change); // 自动转换列名的驼峰命名法
         strategy.setEntityLombokModel(true); // 是否使用lombox

+ 16 - 0
business-entity/src/main/java/com/rongwei/bsentity/vo/CopyNodeVo.java

@@ -0,0 +1,16 @@
+package com.rongwei.bsentity.vo;
+
+import lombok.Data;
+import java.util.List;
+import java.util.Map;
+
+@Data
+public class CopyNodeVo {
+
+    private String projectid;
+
+    private String copysourceid;
+
+    private List<Map<String,Object>> copytoid;
+
+}

+ 4 - 7
business-server/src/main/java/com/rongwei/bsserver/config/NClobTypeHandler.java

@@ -4,10 +4,7 @@ import com.alibaba.druid.pool.DruidDataSource;
 import com.alibaba.druid.proxy.jdbc.NClobProxyImpl;
 import org.apache.ibatis.type.BaseTypeHandler;
 import org.apache.ibatis.type.JdbcType;
-import org.apache.ibatis.type.MappedJdbcTypes;
-import org.apache.ibatis.type.MappedTypes;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
 
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -20,10 +17,10 @@ import java.sql.*;
  *@AUTHOR:赵常飞
  *@date 2023/10/10 16:50
  */
-@MappedTypes(Clob.class)
-@MappedJdbcTypes(JdbcType.CLOB)
-@Component
-public class NClobTypeHandler extends BaseTypeHandler<String> {
+//@MappedTypes(Clob.class)
+//@MappedJdbcTypes(JdbcType.CLOB)
+//@Component
+public class NClobTypeHandlerBs extends BaseTypeHandler<String> {
     @Autowired
     private DruidDataSource datasource;
 

+ 8 - 0
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxItpProjectNodesController.java

@@ -2,12 +2,14 @@ package com.rongwei.bsserver.controller;
 
 
 import com.rongwei.bscommon.sys.service.ZhcxItpProjectNodesService;
+import com.rongwei.bsentity.vo.CopyNodeVo;
 import com.rongwei.rwcommon.base.R;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -31,5 +33,11 @@ public class ZhcxItpProjectNodesController {
         return R.ok();
     }
 
+    @RequestMapping("/copyProjectNode")
+    public R copyProjectNode(@RequestBody CopyNodeVo copyNodeVo){
+        List<Map<String, Object>> maps = zhcxItpProjectNodesService.copyProjectNode(copyNodeVo);
+        return R.ok(maps);
+    }
+
 }