Browse Source

日志新增表单

chenr 1 tháng trước cách đây
mục cha
commit
004f644eb8

+ 107 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java

@@ -3017,6 +3017,113 @@ public class ExcelTabController extends BladeController {
         return R.data(resultMapList);
     }
 
+    /**
+     * 获取新增时的表头数据
+     * @param theLogId
+     * @param nodePrimaryKeyId
+     * @param recordTime
+     * @param contractId
+     * @return
+     * @throws Exception
+     */
+    @GetMapping("/getAddTheLogBusinessData")
+    @ApiOperationSupport(order = 26)
+    @ApiOperation(value = "获取新增表格的默认值")
+    @ApiImplicitParams({
+        @ApiImplicitParam(name = "theLogId", value = "日志记录的ids,可能为空(多张表)"),
+        @ApiImplicitParam(name = "nodePrimaryKeyId", value = "当前操作的日志类型ID,即左侧列表的节点primaryKeyId"),
+        @ApiImplicitParam(name = "recordTime", value = "当前选择的填写日期,即右侧日期控件所选日期,格式为 yyyy-MM-dd"),
+        @ApiImplicitParam(name = "contractId", value = "合同段id")
+    })
+    public R<Map<String, Object>> getAddTheLogBusinessData(String theLogId, String nodePrimaryKeyId, String recordTime, String contractId) throws Exception {
+        Map<String, Object> resultMapList = new HashMap<>();
+        //数据结果
+        String logId2 = "";
+        //获取对应的记录
+        String dataIds;
+        if (StringUtils.isNotEmpty(theLogId)) {
+            String[] split = theLogId.split(",");
+            List<String> ids = new LinkedList<>();
+            for (String logId : split) {
+                ContractLog contractLog = this.contractLogClient.queryContractLogByIdToObj(logId);
+                ids.add(contractLog.getDataId().toString());
+            }
+            dataIds = ids.stream().filter(Objects::nonNull).collect(Collectors.joining(","));
+        } else {
+            List<ContractLog> contractLogs = this.contractLogClient.queryContractLogByPrimaryKeyIdAndRecordTimeList(nodePrimaryKeyId, recordTime, contractId,null);
+            if (contractLogs.size() == 0) {
+                logId2 = "";
+            } else {
+                logId2 = contractLogs.get(0).getId() + "";
+            }
+            dataIds = contractLogs.stream().map(ContractLog::getDataId).filter(Objects::nonNull).map(String::valueOf).collect(Collectors.joining(","));
+        }
+        WbsTreePrivate node;
+        WbsTreePrivate tableNode2;
+        try{
+            node = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, nodePrimaryKeyId));
+            tableNode2= this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery()
+                .eq(WbsTreePrivate::getParentId, node.getId()).eq(WbsTreePrivate::getProjectId, node.getProjectId()));
+        } catch (Exception e) {
+            throw new ServiceException("表单重复,请确认表单");
+        }
+        if (StringUtils.isNotEmpty(dataIds)) {
+            if (dataIds.startsWith(",")) {
+                dataIds = dataIds.substring(1);
+            }
+            String[] ids = dataIds.split(",");
+            //检查实体表是否存在
+            String tabName = tableNode2.getInitTableName();
+            String isExitSql = " select * from information_schema.TABLES where TABLE_NAME='" + tabName + "'";
+            List<Map<String, Object>> tabList = this.jdbcTemplate.queryForList(isExitSql);
+            if (tabList.size() <= 0) {
+                return R.fail("无实体表对应");
+            }
+            //查询数据
+            String querySql = "SELECT * FROM " + tabName + " WHERE id = " + ids[0] + " and group_id = " + tableNode2.getPKeyId();
+            Map<String, Object> businessDataMap = this.jdbcTemplate.queryForMap(querySql);
+            if (businessDataMap.size() > 0){
+                try {
+                    if (tableNode2.getHtmlUrl() != null){
+                        InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(tableNode2.getHtmlUrl());
+                        String htmlString = IoUtil.readToString(inputStreamByUrl);
+                        Document doc = Jsoup.parse(htmlString);
+                        // 模糊匹配
+                        Elements cbdw = doc.select("el-select[placeholder*=承包单位]");
+                        Elements htd = doc.select("el-select[placeholder*=合同段]");
+                        Elements jldw = doc.select("el-input[placeholder*=监理单位]");
+                        Elements jljg = doc.select("el-select[placeholder*=监理机构]");
+                        Elements jlr = doc.select("el-input[placeholder*=记录人]");
+                        Elements rq = doc.select("el-date-picker[placeholder*=日期]");
+                        Elements shr = doc.select("el-input[placeholder*=审核人]");
+                        Elements tqqk = doc.select("el-input[placeholder*=天气情况]");
+                        List<Elements> allElements=new ArrayList<>();
+                        allElements.add(cbdw);
+                        allElements.add(htd);
+                        allElements.add(jldw);
+                        allElements.add(jljg);
+                        allElements.add(jlr);
+                        allElements.add(rq);
+                        allElements.add(shr);
+                        allElements.add(tqqk);
+                        if(allElements.size()>0){
+                            for (Elements element : allElements) {
+                             if(businessDataMap.containsKey(element.attr("keyname"))){
+                                resultMapList.put(element.attr("keyname"), businessDataMap.get(element.attr("keyname")));
+                               }
+                            }
+                        }
+                    }
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        }
+        return R.data(resultMapList);
+    }
+
+
+
     /**
      * 复制指定日期的日志填报数据
      */