Эх сурвалжийг харах

Merge remote-tracking branch 'origin/master' into master

yangyj 2 жил өмнө
parent
commit
251ec2caf7

+ 21 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/feign/ArchiveFileClient.java

@@ -0,0 +1,21 @@
+package org.springblade.business.feign;
+
+import org.springblade.business.vo.ArchiveFileVO;
+import org.springblade.common.constant.BusinessConstant;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+
+/**
+ * @author zhifk
+ */
+@FeignClient(value = BusinessConstant.APPLICATION_WEATHER_NAME)
+public interface ArchiveFileClient {
+    /**
+     * 接口前缀
+     */
+    String API_PREFIX = "/api/business";
+    @PostMapping(API_PREFIX + "/savePushUserMessageWarning")
+    void saveArchiveFile(@RequestBody ArchiveFileVO vo);
+}

+ 8 - 4
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/CopyContractTreeNodeVO.java

@@ -30,8 +30,8 @@ public class CopyContractTreeNodeVO {
     @ApiModelProperty("所属方,1=施工,2=监理,字符串拼接,复制数据")
     private String classify;
 
-    public void setCopyBatchToPaths(String primaryKeyId, String nodeName){
-        this.copyBatchToPaths.add(new CopyBatch(primaryKeyId, nodeName));
+    public void setCopyBatchToPaths(String primaryKeyId, String nodeName, String partitionCode) {
+        this.copyBatchToPaths.add(new CopyBatch(primaryKeyId, nodeName, partitionCode));
     }
 
     @Data
@@ -41,11 +41,15 @@ public class CopyContractTreeNodeVO {
 
         private String nodeName;
 
-        public CopyBatch(){}
+        private String partitionCode;
 
-        public CopyBatch(String primaryKeyId, String nodeName){
+        public CopyBatch() {
+        }
+
+        public CopyBatch(String primaryKeyId, String nodeName, String partitionCode) {
             this.primaryKeyId = primaryKeyId;
             this.nodeName = nodeName;
+            this.partitionCode = partitionCode;
         }
 
     }

+ 0 - 7
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/ContractInfo.java

@@ -157,11 +157,4 @@ public class ContractInfo extends BaseEntity {
     @ApiModelProperty(value = "是否引用编号 '0'否 '1'是")
     private Integer isReferenceNumber;
 
-    /**
-     * 是否开启复制数据 '0'否 '1'是
-     */
-    @ApiModelProperty(value = "是否开启复制数据 '0'否 '1'是")
-    private Integer isCopyData;
-
-
 }

+ 6 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/feign/TableFileClient.java

@@ -4,6 +4,9 @@ import org.springblade.manager.entity.TableFile;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.List;
 
 import static org.springblade.core.launch.constant.AppConstant.APPLICATION_NAME_PREFIX;
 
@@ -19,4 +22,7 @@ public interface TableFileClient {
     @PostMapping(API_PREFIX + "/saveFile")
     void saveFile(@RequestBody TableFile tableFile);
 
+    @PostMapping(API_PREFIX + "/saveBatchFile")
+    void saveBatchFile(@RequestBody List<TableFile> query,@RequestParam Long addTablePkeyId);
+
 }

+ 76 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchiveFileController.java

@@ -0,0 +1,76 @@
+package org.springblade.archive.controller;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import lombok.SneakyThrows;
+import org.springblade.business.entity.ArchiveFile;
+import org.springblade.business.feign.ArchiveFileClient;
+import org.springblade.business.vo.ArchiveFileVO;
+import org.springblade.core.boot.ctrl.BladeController;
+
+import org.springblade.core.oss.model.BladeFile;
+import org.springblade.core.tool.api.R;
+import org.springblade.resource.feign.IOSSClient;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+
+/**
+ *  控制器
+ *
+ * @author BladeX
+ * @since 2022-07-08
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/archiveFile")
+@Api(value = "工程文件接口", tags = "工程文件接口")
+public class ArchiveFileController extends BladeController {
+
+	private final ArchiveFileClient archiveFileClient;
+    private final IOSSClient iossClient;
+    /**
+     * 上传文件
+     *
+     * @param file 文件
+     * @return ObjectStat
+     */
+    @SneakyThrows
+    @PostMapping("/put-file-attach")
+    @ApiOperationSupport(order = 1)
+    @ApiOperation(value = "工程上传", notes = "工程上传")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "file", value = "文件源", required = true)
+    })
+    public R<String> putFileAttach(@RequestParam("file") MultipartFile file) {
+        // 上传工程文件文件
+        R<BladeFile> bladeFile = iossClient.addFileInfo(file);
+
+        return R.data(bladeFile.getData().getLink());
+    }
+    /**
+     * 批量新增
+     */
+    @PostMapping("/batchSave")
+    @ApiOperationSupport(order = 3)
+    @ApiOperation(value = "批量新增")
+    public R<Boolean> batchSave(@RequestBody ArchiveFileVO vo){
+        List<ArchiveFileVO> saveList = vo.getList();
+        if(saveList != null && saveList.size() > 0){
+            for(ArchiveFileVO saveVo : saveList){
+                saveVo.setStatus(new Integer("0").equals(saveVo.getIsApproval()) ? 2 : 0);
+                saveVo.setIsCertification(new Integer("0").equals(saveVo.getIsNeedCertification()) ? 1 : 0);
+            }
+        }
+        archiveFileClient.saveArchiveFile(vo);
+        return R.data(true);
+    }
+}

+ 64 - 37
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -34,7 +34,6 @@ import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.secure.utils.AuthUtil;
-import org.springblade.core.secure.utils.SecureUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.node.ForestNodeMerger;
 import org.springblade.core.tool.utils.Func;
@@ -42,10 +41,7 @@ import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.evisa.feign.EVisaClient;
 import org.springblade.evisa.vo.CertBeanVO;
 import org.springblade.manager.entity.*;
-import org.springblade.manager.feign.ContractClient;
-import org.springblade.manager.feign.ProjectClient;
-import org.springblade.manager.feign.WbsTreeContractClient;
-import org.springblade.manager.feign.WbsTreePrivateClient;
+import org.springblade.manager.feign.*;
 import org.springblade.manager.vo.WbsTreeContractTreeVOS;
 import org.springblade.resource.feign.NewIOSSClient;
 import org.springblade.system.cache.ParamCache;
@@ -61,7 +57,6 @@ import org.springblade.core.boot.ctrl.BladeController;
 
 import java.io.IOException;
 import java.util.*;
-import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 
 /**
@@ -110,6 +105,8 @@ public class InformationWriteQueryController extends BladeController {
 
     private final WebSocket webSocket;
 
+    private final TableFileClient tableFileClient;
+
     /**
      * 获取文件题名
      */
@@ -352,7 +349,7 @@ public class InformationWriteQueryController extends BladeController {
     @ApiOperationSupport(order = 25)
     @ApiOperation(value = "复制节点填报数据")
     public R<Boolean> copyContractNodeSubmitBusinessData(@RequestBody CopyContractTreeNodeVO copyVO) {
-        if (StringUtils.isNotEmpty(copyVO.getClassify())) {
+        if (StringUtils.isEmpty(copyVO.getClassify())) {
             throw new ServiceException("请选择至少一个所属方");
         }
         if (StringUtils.isNotEmpty(copyVO.getNeedCopyPrimaryKeyId()) && copyVO.getCopyBatchToPaths().size() > 0) {
@@ -369,11 +366,15 @@ public class InformationWriteQueryController extends BladeController {
                 }
             }
 
-            //获取被复制节点下的表格,根据所属方
-            String sqlContractNode = "select * from m_wbs_tree_contract where parent_id = " + wbsTreeContract.getId() + " and contract_id = " + wbsTreeContract.getContractId() + " and table_owner in(" + tabOwner + ") and is_deleted = 0";
+            //获取被复制节点下的表格(源表格),根据所属方
+            String sqlContractNode = "select * from m_wbs_tree_contract where parent_id = " + wbsTreeContract.getId() + " and contract_id = " + wbsTreeContract.getContractId() + " and table_owner in(" + tabOwner + ") and is_deleted = 0 and type = 2";
             List<WbsTreeContract> tableList = jdbcTemplate.query(sqlContractNode, new BeanPropertyRowMapper<>(WbsTreeContract.class));
+
+            //新增的表信息
+            List<WbsTreeContract> copyTableInfos = new ArrayList<>();
+
             if (tableList.size() > 0) {
-                //获取表格的业务数据
+                //获取数据
                 Map<String, List<List<Map<String, Object>>>> tableBusinessDataMap = new HashMap<>();
                 for (WbsTreeContract treeContract : tableList) {
                     List<Map<String, Object>> tableBusinessData = this.jdbcTemplate.queryForList("select * from " + treeContract.getInitTableName() + " where p_key_id = " + treeContract.getPKeyId());
@@ -396,45 +397,36 @@ public class InformationWriteQueryController extends BladeController {
                 List<String> removeSqlList = new ArrayList<>();
                 //新增数据SQL
                 List<String> saveSqlList = new ArrayList<>();
+
                 for (CopyContractTreeNodeVO.CopyBatch copyBatch : batchPathList) {
                     //获取选择的节点信息
                     WbsTreeContract selectNode = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(copyBatch.getPrimaryKeyId());
 
-                    //获取合同段信息
-                    ContractInfo contract = this.contractClient.getContractById(Long.parseLong(selectNode.getContractId()));
-
                     //实际获取的数据
                     Map<String, List<List<Map<String, Object>>>> currentDataMap = new HashMap<>();
-                    if (new Integer("1").equals(contract.getIsCopyData())) {
-                        //说明开启数据复制限制,根据合同段类型判断哪些数据是能够被复制的
-                        String removeString = new Integer("1").equals(contract.getContractType()) ? "1,2,3" : "5,6,7";
-                        //找符合条件的表格
-                        List<WbsTreeContract> tables = tableList.stream().filter(tree -> Arrays.asList(removeString.split(",")).contains(tree.getTableOwner())).distinct().collect(Collectors.toList());
-                        if (tables.size() <= 0) {
-                            continue;
-                        }
-                        for (WbsTreeContract node : tables) {
-                            if (tableBusinessDataMap.containsKey(node.getId().toString()) && !currentDataMap.containsKey(node.getId().toString())) {
-                                currentDataMap.put(node.getId().toString(), tableBusinessDataMap.get(node.getId().toString()));
-                            }
+
+                    //根据源表,解析对应的的表
+                    for (WbsTreeContract node : tableList) {
+                        if (tableBusinessDataMap.containsKey(node.getId().toString()) && !currentDataMap.containsKey(node.getId().toString())) {
+                            currentDataMap.put(node.getId().toString(), tableBusinessDataMap.get(node.getId().toString()));
                         }
                     }
 
                     //获取表格信息
                     List<WbsTreeContract> copyToTableList = this.wbsTreeContractClient.queryChildByParentId(selectNode, "queryTable", "");
-                    if (copyToTableList != null && copyToTableList.size() > 0) {
-                        //首先,记录数据删除sql
-                        for (WbsTreeContract table : copyToTableList) {
-                            if (StringUtils.isNotEmpty(table.getInitTableName())) {
-                                removeSqlList.add("delete from " + table.getInitTableName() + " where p_key_id = " + table.getPKeyId());
-                            }
-                        }
 
-                        //其次,检测是否表格是否存在差异(如果存在oldId则优先使用这个字段,不存在时才使用id)
+                    if (copyToTableList != null && copyToTableList.size() > 0) {
+                        //检测是否表格是否存在差异(如果存在oldId则优先使用这个字段,不存在时才使用id)
                         List<WbsTreeContract> remainTableList = copyToTableList.stream().filter(toTable -> currentDataMap.containsKey(StringUtils.isNotEmpty(toTable.getOldId()) ? toTable.getOldId() : toTable.getId().toString())).collect(Collectors.toList());
+
                         //循环有数据的表格
                         for (WbsTreeContract remainTable : remainTableList) {
                             if (StringUtils.isNotEmpty(remainTable.getInitTableName())) {
+                                //附件信息ids
+                                copyTableInfos.add(remainTable);
+                                //数据删除sql,做覆盖操作
+                                removeSqlList.add("delete from " + remainTable.getInitTableName() + " where p_key_id = " + remainTable.getPKeyId());
+
                                 //获取主键
                                 String id = StringUtils.isNotEmpty(remainTable.getOldId()) ? remainTable.getOldId() : remainTable.getId().toString();
                                 if (currentDataMap.containsKey(id)) {
@@ -462,9 +454,9 @@ public class InformationWriteQueryController extends BladeController {
                                             }
                                             //生成最终sql
                                             saveSqlList.add(sql.append(")").append(valueSql).append(")").toString());
-                                            iterator.remove();
                                             break;
                                         }
+
                                         if (dataMapList.size() <= 0) {
                                             oneLevelIterator.remove();
                                         }
@@ -475,7 +467,7 @@ public class InformationWriteQueryController extends BladeController {
                         }
                     }
                 }
-                //删除原本填写的数据
+                //删除原本填写的数据,覆盖
                 if (removeSqlList.size() > 0) {
                     for (String sql : removeSqlList) {
                         this.jdbcTemplate.execute(sql);
@@ -488,8 +480,39 @@ public class InformationWriteQueryController extends BladeController {
                         this.jdbcTemplate.execute(sql);
                     }
                 }
-                return R.data(true);
+
+            }
+
+            //复制附件信息
+            for (WbsTreeContract sourceDataObj : tableList) {
+                if (sourceDataObj.getTabFileType() == 2) {
+                    //获取源表中的附件信息
+                    String sql = "select * from m_table_file where is_deleted = 0 and type = 2 and tab_id =" + sourceDataObj.getPKeyId();
+                    List<TableFile> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TableFile.class));
+                    if (query.size() > 0) {
+                        Iterator<WbsTreeContract> iterator = copyTableInfos.iterator();
+                        while (iterator.hasNext()) {
+                            WbsTreeContract next = iterator.next();
+                            if (sourceDataObj.getNodeName().equals(next.getNodeName())) { //如果原表的nodeName=复制节点表的nodeName,那么获取原表附件信息
+                                //删除复制节点下对应表的附件信息,覆盖
+                                String del = "delete from m_table_file where tab_id = '" + next.getPKeyId() + "'";
+                                jdbcTemplate.execute(del);
+
+                                //新增源数据附件到复制节点下对应表中
+                                tableFileClient.saveBatchFile(query, next.getPKeyId());
+
+                                //修改复制节点下对应表的按钮状态
+                                String updateStatus = "update m_wbs_tree_contract set tab_file_type = " + sourceDataObj.getTabFileType() + " ,is_tab_pdf = " + sourceDataObj.getIsTabPdf() + " ,pdf_url = '" + sourceDataObj.getPdfUrl() + "' ,is_buss_show = " + sourceDataObj.getIsBussShow() + " where p_key_id = " + next.getPKeyId();
+                                jdbcTemplate.execute(updateStatus);
+
+                                iterator.remove();
+                            }
+                        }
+                    }
+                }
             }
+
+            return R.data(true);
         }
 
         return R.data(300, false, "被复制节点未找到业务数据");
@@ -1095,7 +1118,7 @@ public class InformationWriteQueryController extends BladeController {
                     newData.setPKeyId(SnowFlakeUtil.getId());
                     //设置旧ID
                     if (StringUtils.isNotEmpty(node.getOldId())) {
-                        newData.setOldId(node.getOldId().toString());
+                        newData.setOldId(node.getOldId());
                     } else {
                         newData.setOldId(node.getId().toString());
                     }
@@ -1126,6 +1149,8 @@ public class InformationWriteQueryController extends BladeController {
                     //初始化PDF路径
                     newData.setPdfUrl(null);
                     newData.setCreateUser(AuthUtil.getUserId());
+                    //划分编号
+                    newData.setPartitionCode(StringUtils.isNotEmpty(node.getPartitionCode()) ? node.getPartitionCode() : null);
 
                     //获取当前所有复制的节点的最大sort
                     String sql = "select sort from m_wbs_tree_contract where contract_id = '" + node.getContractId() + "' and (id = '" + node.getId() + "' or old_id = '" + node.getId() + "')";
@@ -1199,6 +1224,8 @@ public class InformationWriteQueryController extends BladeController {
                         newData.setIsTabPdf(1);
                         //初始化PDF路径
                         newData.setPdfUrl(null);
+                        //划分编号
+                        newData.setPartitionCode(StringUtils.isNotEmpty(copyBatch.getPartitionCode()) ? copyBatch.getPartitionCode() : null);
 
                         //获取当前所有复制的节点的最大sort
                         String sql = "select sort from m_wbs_tree_contract where contract_id = '" + node.getContractId() + "' and (id = '" + node.getId() + "' or old_id = '" + node.getId() + "')";

+ 21 - 0
blade-service/blade-business/src/main/java/org/springblade/business/feignClient/ArchiveFileClientImpl.java

@@ -0,0 +1,21 @@
+package org.springblade.business.feignClient;
+
+import lombok.AllArgsConstructor;
+import org.springblade.business.feign.ArchiveFileClient;
+import org.springblade.business.service.IArchiveFileService;
+import org.springblade.business.vo.ArchiveFileVO;
+import org.springframework.web.bind.annotation.RestController;
+
+
+@RestController
+@AllArgsConstructor
+public class ArchiveFileClientImpl implements ArchiveFileClient {
+
+    private final IArchiveFileService iArchiveFileService;
+
+
+    @Override
+    public void saveArchiveFile(ArchiveFileVO vo) {
+        this.iArchiveFileService.saveArchiveFile(vo.getList());
+    }
+}

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/service/IArchiveFileService.java

@@ -47,5 +47,5 @@ public interface IArchiveFileService extends BaseService<ArchiveFile> {
 	List<ArchiveFile> getDeleteDataByIds(List<String> ids);
 
 
-
+	void saveArchiveFile(List<ArchiveFileVO> list);
 }

+ 5 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/ArchiveFileServiceImpl.java

@@ -88,4 +88,9 @@ public class ArchiveFileServiceImpl extends BaseServiceImpl<ArchiveFileMapper, A
 		return baseMapper.getDeleteDataByIds(ids);
 	}
 
+	@Override
+	public void saveArchiveFile(List<ArchiveFileVO> list) {
+		this.saveBatch(JSONArray.parseArray(JSONObject.toJSONString(list), ArchiveFile.class));
+	}
+
 }

+ 12 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/TableFileClientImpl.java

@@ -1,10 +1,13 @@
 package org.springblade.manager.feign;
 
 import lombok.AllArgsConstructor;
+import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.manager.entity.TableFile;
 import org.springblade.manager.service.ITableFileService;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+
 
 @RestController
 @AllArgsConstructor
@@ -17,5 +20,14 @@ public class TableFileClientImpl implements TableFileClient {
         tableFileService.save(tableFile);
     }
 
+    @Override
+    public void saveBatchFile(List<TableFile> query, Long addTablePkeyId) {
+        for (TableFile tableFile : query) {
+            tableFile.setId(SnowFlakeUtil.getId());
+            tableFile.setTabId(addTablePkeyId.toString());
+        }
+        this.tableFileService.saveBatch(query, 100);
+    }
+
 
 }

+ 0 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ContractInfoMapper.xml

@@ -41,7 +41,6 @@
         <result column="is_electronic_signature" property="isElectronicSignature"/>
         <result column="is_test_module" property="isTestModule"/>
         <result column="is_reference_number" property="isReferenceNumber"/>
-        <result column="is_copy_data" property="isCopyData"/>
     </resultMap>
 
     <resultMap id="contractInfoResultMap1" type="org.springblade.manager.vo.ContractlnfoCountVO">

+ 3 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ProjectInfoMapper.xml

@@ -56,11 +56,11 @@
     <select id="queryProjectUserAmount" resultMap="projectUserAmount">
         select
             mpi.project_alias,
-            (select count(1) end from m_project_assignment_user where is_deleted = 0 and project_id = mpi.id and role_id in
+            (select COUNT(DISTINCT user_id)  end from m_project_assignment_user where is_deleted = 0 and project_id = mpi.id and role_id in
                 (select id from blade_role where is_deleted = 0 and (id = '1537247986361782274' or parent_id = '1537247986361782274' ))) as contractor,
-            (select count(1) end from m_project_assignment_user where is_deleted = 0 and project_id = mpi.id and role_id in
+            (select COUNT(DISTINCT user_id)  end from m_project_assignment_user where is_deleted = 0 and project_id = mpi.id and role_id in
                 (select id from blade_role where is_deleted = 0 and (id = '1537246384519335938' or parent_id = '1537246384519335938'))) as supervision,
-            (select count(1) end from m_project_assignment_user where is_deleted = 0 and project_id = mpi.id and role_id in
+            (select COUNT(DISTINCT user_id)  end from m_project_assignment_user where is_deleted = 0 and project_id = mpi.id and role_id in
                 (select id from blade_role where is_deleted = 0 and (id = '1537246243393589249' or parent_id = '1537246243393589249'))) as owner
         from
             m_project_info as mpi