Kaynağa Gözat

试验汇总

Signed-off-by: liuyc <56808083@qq.com>
liuyc 8 ay önce
ebeveyn
işleme
83e30866f5

+ 3 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/ExcelTabTreeVO.java

@@ -11,4 +11,7 @@ public class ExcelTabTreeVO extends ExcelTab {
     @ApiModelProperty(value = "回显状态 1=勾选")
     private Integer recordStatus;
 
+    @ApiModelProperty(value = "是否有子级")
+    private boolean hasChildren;
+
 }

+ 0 - 1
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/MeterContractInfo.java

@@ -5,7 +5,6 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.springblade.core.mp.base.BaseEntity;
 
-import java.io.Serializable;
 import java.math.BigDecimal;
 
 /**

+ 2 - 2
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialSummaryController.java

@@ -71,7 +71,7 @@ public class TrialSummaryController {
     @GetMapping("/contract/list")
     @ApiOperationSupport(order = 1)
     @ApiOperation(value = "合同段下拉框", notes = "传入当前登陆选择的合同段id、项目id")
-    public R<Object> list(@RequestParam String contractId, @RequestParam String projectId) {
+    public R<List<ContractInfo>> list(@RequestParam String contractId, @RequestParam String projectId) {
         ContractInfo contractInfo = jdbcTemplate.query(
                 "SELECT * FROM m_contract_info WHERE is_deleted = 0 AND status = 1 AND id = ?",
                 new Object[]{contractId},
@@ -85,7 +85,7 @@ public class TrialSummaryController {
             );
             return R.data(contractInfoList);
         }
-        return R.data(contractInfo);
+        return R.data(Collections.singletonList(contractInfo));
     }
 
     @GetMapping("/list")

+ 10 - 11
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/TrialSummaryClassificationConfigurationController.java

@@ -18,7 +18,6 @@ import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
-import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.IoUtil;
 import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.core.tool.utils.ResourceUtil;
@@ -26,7 +25,6 @@ import org.springblade.manager.dto.TrialSummaryClassificationConfigurationMatchD
 import org.springblade.manager.dto.TrialSummaryClassificationConfigurationRelevancyDTO;
 import org.springblade.manager.dto.TrialSummaryReflectionSaveDTO;
 import org.springblade.manager.entity.*;
-import org.springblade.manager.mapper.ExcelTabMapper;
 import org.springblade.manager.service.ITrialSummaryClassificationConfigurationService;
 import org.springblade.manager.service.IWbsFormElementService;
 import org.springblade.manager.service.impl.WbsTreePrivateServiceImpl;
@@ -40,10 +38,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
 import java.io.*;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 
@@ -55,7 +50,6 @@ public class TrialSummaryClassificationConfigurationController extends BladeCont
 
     private final ITrialSummaryClassificationConfigurationService iTrialSummaryClassificationConfigurationService;
     private final WbsTreePrivateServiceImpl wbsTreePrivateServiceImpl;
-    private final ExcelTabMapper excelTabMapper;
     private final JdbcTemplate jdbcTemplate;
     private final IWbsFormElementService wbsFormElementService;
 
@@ -113,8 +107,12 @@ public class TrialSummaryClassificationConfigurationController extends BladeCont
     @ApiOperation(value = "关联清表-清表懒加载", notes = "清表列表调/api/blade-manager/exceltab/page接口;传入父级id、modeId、分类classId")
     @RequestMapping(value = "/lazy", method = RequestMethod.GET)
     public R<List<ExcelTabTreeVO>> lazy(@RequestParam String parentId, @RequestParam String modeId, @RequestParam String classId) {
-        List<ExcelTab> excelTabs = excelTabMapper.selectList(Wrappers.<ExcelTab>lambdaQuery().eq(ExcelTab::getParentId, parentId).like(ExcelTab::getAlias, modeId));
-        List<ExcelTabTreeVO> excelTabTreeVOS = BeanUtil.copyProperties(excelTabs, ExcelTabTreeVO.class);
+        List<ExcelTabTreeVO> excelTabTreeVOS = jdbcTemplate.query("SELECT *," +
+                        "   (SELECT CASE WHEN COUNT(1) > 0 THEN true ELSE false END FROM m_excel_tab b" +
+                        "       WHERE b.is_deleted = 0 AND a.id = b.parent_id) AS hasChildren" +
+                        " FROM m_excel_tab a WHERE a.parent_id = ? AND a.alias LIKE ? AND a.is_deleted = 0"
+                , new Object[]{parentId, "%" + modeId + "%"}
+                , new BeanPropertyRowMapper<>(ExcelTabTreeVO.class));
         TrialSummaryClassificationConfiguration classificationConfiguration = iTrialSummaryClassificationConfigurationService.getById(classId);
         if (classificationConfiguration != null) {
             for (ExcelTabTreeVO excelTabTreeVO : excelTabTreeVOS) {
@@ -228,7 +226,8 @@ public class TrialSummaryClassificationConfigurationController extends BladeCont
                 TrialSummaryClassificationConfiguration classificationConfiguration = iTrialSummaryClassificationConfigurationService.getById(dto.getClassId());
                 if (classificationConfiguration != null && ObjectUtil.isNotEmpty(classificationConfiguration.getExcelId())) {
                     List<TrialSummaryReflectionSaveDTO.ReflectionBean> reflectionBeanList = dto.getReflectionBeanList();
-                    List<String> keyNameList = reflectionBeanList.stream()
+                    Set<TrialSummaryReflectionSaveDTO.ReflectionBean> collect = new HashSet<>(reflectionBeanList);
+                    List<String> keyNameList = collect.stream()
                             .map(bean -> "'" + bean.getHtmlKeyName() + "'")
                             .collect(Collectors.toList());
                     if (keyNameList.size() <= 0) {
@@ -243,7 +242,7 @@ public class TrialSummaryClassificationConfigurationController extends BladeCont
 
                     String sqlInsert = "INSERT INTO m_trial_summary_excel_tab_reflection(id,excel_id,trial_tab_id,element_id,html_key_name,trial_tab_name,element_key) VALUES (?,?,?,?,?,?,?)";
                     List<Object[]> batchArgs = new ArrayList<>();
-                    for (TrialSummaryReflectionSaveDTO.ReflectionBean reflectionBean : reflectionBeanList) {
+                    for (TrialSummaryReflectionSaveDTO.ReflectionBean reflectionBean : collect) {
                         Object[] paramsInsert = {
                                 SnowFlakeUtil.getId(),
                                 classificationConfiguration.getExcelId(),

+ 10 - 22
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/TrialSummaryClassificationConfigurationServiceImpl.java

@@ -1,6 +1,5 @@
 package org.springblade.manager.service.impl;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.AllArgsConstructor;
@@ -19,25 +18,21 @@ import org.springblade.manager.dto.TrialSummaryClassificationConfigurationReleva
 import org.springblade.manager.entity.*;
 import org.springblade.manager.mapper.TrialSummaryClassificationConfigurationMapper;
 import org.springblade.manager.service.IExcelTabService;
-import org.springblade.manager.service.ITableInfoService;
 import org.springblade.manager.service.ITrialSummaryClassificationConfigurationService;
 import org.springblade.manager.service.IWbsFormElementService;
 import org.springblade.manager.utils.FileUtils;
 import org.springblade.manager.utils.RegularExpressionUtil;
 import org.springblade.manager.utils.WbsElementUtil;
 import org.springblade.manager.vo.TrialTreeVO;
-import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import java.util.function.Function;
 import java.util.stream.Collectors;
 
 @Service
@@ -81,33 +76,32 @@ public class TrialSummaryClassificationConfigurationServiceImpl
     @Override
     public boolean relevancy(TrialSummaryClassificationConfigurationRelevancyDTO dto) throws IOException {
         if (ObjectUtil.isNotEmpty(dto.getExcelId()) && ObjectUtil.isNotEmpty(dto.getClassId())) {
-            /*关联清表,重新生成html,重构定位信息*/
-            String file_path = FileUtils.getSysLocalFileUrl();
+            /*上传excel清表模板后,需要元素识别并添加到元素库;
+            然后调该接口关联清表,重新生成html,重构定位信息*/
             ExcelTab excelTab = excelTabService.getById(dto.getExcelId());
             if (ObjectUtil.isEmpty(excelTab)) {
                 throw new ServiceException("未获取到清表信息");
             }
             if (ObjectUtil.isEmpty(excelTab.getTabId())) {
-                throw new ServiceException("未获取到清表tabId信息");
+                throw new ServiceException("tabId为空,请先在元素识别中添加到元素库");
             }
             List<WbsFormElement> elementList = wbsFormElementService.selectElementListByFid(excelTab.getTabId());
             if (elementList.size() == 0) {
-                throw new ServiceException("未获取到清表对应元素信息");
+                throw new ServiceException("未获取到元素信息");
             }
 
             //复制模版htmlURL
             //File file_in = ResourceUtil.getFile("C:\\Users\\泓创开发\\Desktop\\fsdownload\\1717821792510279680.html");
             File file_in = ResourceUtil.getFile(excelTab.getHtmlUrl());
             String fileCode = SnowFlakeUtil.getId() + "";
+            String file_path = FileUtils.getSysLocalFileUrl();
             String htmlUrl = file_path + "/privateUrl/" + fileCode + ".html";
             File file_out = ResourceUtil.getFile(htmlUrl);
             FileUtil.copy(file_in, file_out);
 
-            //匹配关联
             File file1 = ResourceUtil.getFile(htmlUrl);
             String htmlString = IoUtil.readToString(new FileInputStream(file1));
             Document doc = Jsoup.parse(htmlString);
-            //解析
             Element table = doc.select("table").first();
             Elements trs = table.select("tr");
             for (int i = 0; i < trs.size(); i++) {
@@ -115,8 +109,7 @@ public class TrialSummaryClassificationConfigurationServiceImpl
                 Elements tds = tr.select("td");
                 for (int j = 0; j < tds.size(); j++) {
                     Element element = tds.get(j);
-                    if (element.html().indexOf("el-input") >= 0 || element.html().indexOf("el-date-picker") >= 0) {
-
+                    if (element.html().contains("el-input") || element.html().contains("el-date-picker")) {
                         boolean is_true = false;
                         String titleName = element.attr("title");
                         double maxScore = 0.48;
@@ -124,7 +117,6 @@ public class TrialSummaryClassificationConfigurationServiceImpl
                         String attrInfo = "key" + "__" + i + "_" + j;
                         String filedType = "";
                         String filedLength = "";
-
                         for (WbsFormElement elementInfo : elementList) {
                             String ysName = elementInfo.getEName();
                             if (titleName.equals(ysName)) {
@@ -152,36 +144,32 @@ public class TrialSummaryClassificationConfigurationServiceImpl
                                 }
                             }
                         }
-                        String oncklickText = "'" + lastName + "'," + i + "," + j;
-
-                        //字段正则表达式校验
+                        String onClickText = "'" + lastName + "'," + i + "," + j;
                         String regularExpression = "$event" + "," + "'" + RegularExpressionUtil.getRegularExpression(filedType) + "','" + (StringUtils.isNotEmpty(filedType) ? WbsElementUtil.getTypeTips(filedType) : null) + "'," + i + "," + j;
-
                         if (is_true) {
                             element.children().get(0).attr("placeholder", lastName)
                                     .attr("weighing", maxScore + "").attr("id", attrInfo).attr("keyName", attrInfo)
                                     .attr("@blur", "getRegularExpression(" + regularExpression + ",'" + filedLength + "')")
                                     .attr("v-model", "formData." + attrInfo)
                                     .attr("maxlength", filedLength);
-                            if (element.html().indexOf("el-input") >= 0) {
+                            if (element.html().contains("el-input")) {
                                 String mousedown = "$event" + "," + "'" + attrInfo + "'";
                                 element.children().get(0).attr("@mouseup.left", "inputLeftClick(" + mousedown + ")");
                             }
                         } else {
                             element.children().get(0)
-                                    //.attr("placeholder", lastName)
                                     .attr("weighing", maxScore + "").attr("id", attrInfo).attr("keyName", attrInfo)
                                     .attr("@blur", "getRegularExpression(" + regularExpression + ",'" + filedLength + "')")
                                     .attr("maxlength", filedLength)
                                     .attr("class", "warnstyle");
                         }
-                        element.attr("@click", "getInformation(" + oncklickText + ")");
+                        element.attr("@click", "getInformation(" + onClickText + ")");
                     }
                 }
             }
 
             File writeFile = new File(htmlUrl);
-            FileUtil.writeToFile(writeFile, doc.html(), Boolean.parseBoolean("UTF-8"));
+            FileUtil.writeToFile(writeFile, doc.html(), false);
 
             String updateSql = "UPDATE m_trial_summary_classification_configuration SET excel_id = ?,html_url = ? WHERE id = ?";
             Object[] delParams = {dto.getExcelId(), htmlUrl, dto.getClassId()};