瀏覽代碼

试验系统试验汇总优化

lvy 2 周之前
父節點
當前提交
9888359eb5

+ 1 - 1
blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialSummaryRecordDTO.java

@@ -17,7 +17,7 @@ public class TrialSummaryRecordDTO implements Serializable {
     @ApiModelProperty(value = "检测类型")
     private Integer detectionType;
 
-    @ApiModelProperty(value = "单位类型")
+    @ApiModelProperty(value = "单位类型, 1施工,2监理,3业主")
     private Integer unitType;
 
     @ApiModelProperty(value = "汇总开始时间,格式yyyy-MM-dd")

+ 3 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/TrialSummaryClassificationConfiguration.java

@@ -32,4 +32,7 @@ public class TrialSummaryClassificationConfiguration extends BaseEntity {
     @ApiModelProperty(value = "排序")
     private Integer sort;
 
+    @ApiModelProperty(value = "项目类型,0:公路工程, 1:水利工程")
+    private Integer projectType;
+
 }

+ 80 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/TrialTableDataInfo.java

@@ -0,0 +1,80 @@
+package org.springblade.manager.vo;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Data;
+import lombok.Getter;
+import org.springblade.manager.entity.WbsFormElement;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+
+@Data
+public class TrialTableDataInfo implements java.io.Serializable {
+    private static final long serialVersionUID = 1L;
+    public static final String ID="203700000001";
+    public static final Long LONG_ID=203700000001L;
+    public static final String TBN="TrialTableDataInfo";
+    public static final String TBN_CH="试验表格数据";
+    static final String UNKNOWN="未设置";
+
+    public static List<WbsFormElement> getElementList() {
+        TrialTableElementEnum[] values = TrialTableElementEnum.values();
+        List<WbsFormElement> result = new ArrayList<>();
+        for (TrialTableElementEnum value : values) {
+            WbsFormElement element = new WbsFormElement();
+            element.setId(value.id);
+            element.setEKey(value.key);
+            element.setEName(value.cnName);
+            element.setEType(1);
+            element.setELength(200);
+            element.setIsDeleted(0);
+            element.setStatus(1);
+            result.add(element);
+        }
+        return result;
+    }
+
+    public static String getElementName(String key) {
+        TrialTableElementEnum[] values = TrialTableElementEnum.values();
+        for (TrialTableElementEnum value : values) {
+            if (value.key.equals(key)) {
+                return value.cnName;
+            }
+        }
+        return UNKNOWN;
+    }
+
+    @Getter
+    public static enum TrialTableElementEnum {
+        RECORD_NO(203700000001001L, "key_301","recordNo", "记录编号"),
+        REPORT_NO(203700000001002L, "key_302","reportNo", "报告编号"),
+        ENTRUST_NO(203700000001003L, "key_303","entrustNo", "委托单编号"),
+        SPECIFICATION_NUMBER(203700000001004L, "key_304","specificationNumber", "样品编号"),
+        TRIAL_PROJECT_NAME(203700000001005L, "key_305","trialProjectName", "试验项目名称"),
+        TASK_STATUS(203700000001006L, "key_306","taskStatus", "任务状态"),
+        REPORT_DATE(203700000001007L, "key_307","reportDate", "报告日期"),
+        TRIAL_USER_NAME(203700000001008L, "key_308","trialUserName", "试验人员"),
+        DETECTION_CATEGORY(203700000001009L, "key_309","detectionCategory", "检测类别"),
+        SPECIFICATION_MODEL(203700000001010L, "key_310","specificationModel", "规格类型"),
+        PROJECT_POSITION(203700000001011L, "key_311","projectPosition", "工程部位及用途"),
+        SAMPLING_LOCATION(203700000001012L, "key_312","samplingLocation", "取样地点"),
+        IS_UPLOAD_CERTIFICATE(203700000001013L, "key_313","isUploadCertificate", "是否上传合格证"),
+        ENTRUST_NAME(203700000001014L, "key_314","entrustName", "委托单名称"),
+        CONTRACT_NAME(203700000001015L, "key_315","contractName", "合同段"),
+        COMPANY(203700000001016L, "key_316","company", "单位"),
+        DETECTION_RESULT(203700000001017L, "key_317","detectionResult", "检测结果"),
+        ;
+        private final Long id;
+        private final String key;
+        private final String enName;
+        private final String cnName;
+        TrialTableElementEnum(Long id, String key, String enName, String chName) {
+            this.id = id;
+            this.key = key;
+            this.cnName = chName;
+            this.enName = enName;
+        }
+    }
+}

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

@@ -3,6 +3,7 @@ package org.springblade.business.controller;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fasterxml.jackson.core.JsonProcessingException;
@@ -21,13 +22,15 @@ import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
+import org.springblade.business.dto.TrialSeleInspectionRecordBaseInfoDTO;
 import org.springblade.business.dto.TrialSummaryRecordDTO;
 import org.springblade.business.dto.TrialSummaryRecordPageDTO;
-import org.springblade.business.entity.TrialSelfInspectionRecord;
-import org.springblade.business.entity.TrialSummaryRecord;
-import org.springblade.business.entity.TrialSummaryRecordDataJson;
+import org.springblade.business.entity.*;
 import org.springblade.business.service.impl.TrialSelfInspectionRecordServiceImpl;
 import org.springblade.business.service.impl.TrialSummaryRecordServiceImpl;
+import org.springblade.business.vo.TrialRawMaterialSelfRecord;
+import org.springblade.business.vo.TrialSelfInspectionRecordVO;
+import org.springblade.business.vo.TrialSelfSample;
 import org.springblade.business.vo.TrialSummaryRecordVO;
 import org.springblade.common.constant.CommonConstant;
 import org.springblade.common.utils.CommonUtil;
@@ -36,16 +39,16 @@ import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.*;
-import org.springblade.manager.entity.ContractInfo;
-import org.springblade.manager.entity.ExcelTab;
-import org.springblade.manager.entity.TrialSummaryClassificationConfiguration;
-import org.springblade.manager.entity.TrialSummaryExcelTabReflection;
+import org.springblade.manager.entity.*;
+import org.springblade.manager.vo.TrialTableDataInfo;
 import org.springblade.resource.feign.NewIOSSClient;
 import org.springblade.resource.vo.NewBladeFile;
 import org.springblade.system.cache.ParamCache;
 import org.springblade.system.entity.Dict;
+import org.springframework.beans.BeanUtils;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.SingleColumnRowMapper;
 import org.springframework.mock.web.MockMultipartFile;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -156,7 +159,8 @@ public class TrialSummaryController {
                     vo.setClassIdName(classificationConfigurationMap.get(obj.getClassId()).getClassName());
                     vo.setDetectionTypeName(dictMap.get(obj.getDetectionType().toString()).getDictValue());
                     vo.setSummaryDateName(obj.getStartDate() + "~" + obj.getEndDate());
-                    vo.setUnitTypeName(obj.getUnitType().equals(1) ? "施工" : "监理");
+                    vo.setUnitTypeName(obj.getUnitType().equals(1) ? "施工" : obj.getUnitType().equals(2) ? "监理" : "业主");
+                    vo.setClassIdName(vo.getClassIdName() + "(" + vo.getUnitTypeName() + ")");
                     return vo;
                 }).collect(Collectors.toList());
         page.setRecords(collect);
@@ -191,6 +195,7 @@ public class TrialSummaryController {
                     .in(TrialSelfInspectionRecord::getNodeId, Func.toLongList(classC.getTrialTreeIds()))
                     .eq(TrialSelfInspectionRecord::getContractId, dto.getContractId())
                     .eq(TrialSelfInspectionRecord::getDetectionCategory, dto.getDetectionType())
+                    .eq(TrialSelfInspectionRecord::getType, dto.getUnitType())
                     .between(TrialSelfInspectionRecord::getReportDate, startDate, endDate)
             );
             if (records.size() <= 0) {
@@ -208,6 +213,7 @@ public class TrialSummaryController {
 
             /*构造实体数据map*/
             Map<String, Object> map = new LinkedHashMap<>();
+            List<Map<String, Object>> trialTableData = trialSelfInspectionRecordServiceImpl.getTrialTableData(recordIds);
             for (Map.Entry<String, List<TrialSummaryExcelTabReflection>> entry : maps.entrySet()) {
                 String tabName = entry.getKey().split("###")[0];
                 String tabPkeyId = entry.getKey().split("###")[1];
@@ -215,9 +221,17 @@ public class TrialSummaryController {
                 List<TrialSummaryExcelTabReflection> value = entry.getValue();
                 Map<String, List<TrialSummaryExcelTabReflection>> elementKeyWithHtmlKeyNameMap = value.stream().collect(Collectors.groupingBy(TrialSummaryExcelTabReflection::getElementKey));
                 Set<String> elementKeys = elementKeyWithHtmlKeyNameMap.keySet();
-
-                String sql_3 = "SELECT " + String.join(",", elementKeys) + " FROM " + tabName + " WHERE p_key_id = " + tabPkeyId + " AND group_id in(" + StringUtils.join(recordIds, ",") + ")";
-                List<Map<String, Object>> tabDataList = jdbcTemplate.queryForList(sql_3);
+                List<Map<String, Object>> tabDataList;
+                if (TrialTableDataInfo.TBN.equals(tabName)) {
+                    if (trialTableData != null && !trialTableData.isEmpty()) {
+                        tabDataList = trialTableData;
+                    } else {
+                        tabDataList = new ArrayList<>();
+                    }
+                } else {
+                    String sql_3 = "SELECT " + String.join(",", elementKeys) + " FROM " + tabName + " WHERE p_key_id = " + tabPkeyId + " AND group_id in(" + StringUtils.join(recordIds, ",") + ")";
+                    tabDataList = jdbcTemplate.queryForList(sql_3);
+                }
                 if (tabDataList.isEmpty()) {
                     continue;
                 }
@@ -329,7 +343,7 @@ public class TrialSummaryController {
             if (indexMap.size() > 0) {
                 ExcelTab excelTab = jdbcTemplate.query("SELECT file_url FROM m_excel_tab WHERE id = ?", new Object[]{classC.getExcelId()}, new BeanPropertyRowMapper<>(ExcelTab.class)).stream().findAny().orElse(null);
                 if (excelTab != null) {
-                    List<MultipartFile> files = this.writeDataToMultipartFile(excelTab.getFileUrl(), indexMap);
+                    List<MultipartFile> files = this.writeDataToMultipartFile(excelTab.getFileUrl(), indexMap, dto.getContractId());
                     if (files.size() > 0) {
                         NewBladeFile newBladeFile = newIOSSClient.excelToPdfs(files);
                         if (newBladeFile != null) {
@@ -381,7 +395,7 @@ public class TrialSummaryController {
      * @return
      * @throws Exception
      */
-    private List<MultipartFile> writeDataToMultipartFile(String fileUrl, Map<String, String> indexMap) throws Exception {
+    private List<MultipartFile> writeDataToMultipartFile(String fileUrl, Map<String, String> indexMap, Long contractId) throws Exception {
         /*pageSize分页分组*/
         Map<String, List<Map.Entry<String, String>>> groupedByPageSize = indexMap.entrySet().stream()
                 .collect(Collectors.groupingBy(entry -> {
@@ -390,7 +404,9 @@ public class TrialSummaryController {
                 }));
 
         List<MultipartFile> files = new LinkedList<>();
-
+        List<String> query = jdbcTemplate.query("select project_name from m_project_info a left join m_contract_info b on a.id = b.p_id where b.id =" + contractId, new SingleColumnRowMapper<>(String.class));
+        String projectName = query.isEmpty()? "" : query.get(0);
+        indexMap.put("projectName", projectName);
         /*每一页视为一份新excel*/
         for (Map.Entry<String, List<Map.Entry<String, String>>> page : groupedByPageSize.entrySet()) {
             InputStream modInput = CommonUtil.getOSSInputStream(fileUrl);
@@ -416,6 +432,47 @@ public class TrialSummaryController {
                         /*根据位置信息,将value写入excel*/
                         mergeAndCenterCells(sheet, x1, x2, y1, y2, value);
                     }
+                    //标题添加
+                    sheet.setForceFormulaRecalculation(true);
+                    int all = 0;
+                    List<CellRangeAddress> mergedRegions = sheet.getMergedRegions();
+                    int xle = Math.min(mergedRegions.size(), 10);
+                    for (int i = 0; i < xle; i++) {
+                        CellRangeAddress mergedCell = sheet.getMergedRegion(i);
+                        int xx = mergedCell.getLastColumn();
+                        if (xx >= all) {
+                            all = xx;
+                        }
+                    }
+                    for (int i = 0; i < xle; i++) {
+                        CellRangeAddress mergedCell = sheet.getMergedRegion(i);
+                        int xx = mergedCell.getLastColumn() + 2;
+                        if (xx >= all) {
+                            int fisRow = mergedCell.getFirstRow();
+                            int firsrCol = mergedCell.getFirstColumn();
+                            Cell cell = sheet.getRow(fisRow).getCell(firsrCol);
+                            short fontIndex = cell.getCellStyle().getFontIndex();
+                            Font oldfontAt = workbook.getFontAt(fontIndex);
+                            Font redFont = workbook.createFont();
+                            redFont.setFontHeightInPoints(oldfontAt.getFontHeightInPoints());//设置字体大小
+                            redFont.setFontName(oldfontAt.getFontName());//设置字体
+                            CellStyle newStyle = workbook.createCellStyle(); //创建单元格样式
+                            newStyle.cloneStyleFrom(cell.getCellStyle());
+                            short fontHeightInPoints = redFont.getFontHeightInPoints();
+                            if (fontHeightInPoints >= 10 && StringUtils.isBlank(cell.getStringCellValue()) && fisRow <= 8) {
+                                String title = indexMap.get("projectName");
+                                if (title.length() >= 30) {
+                                    sheet.getRow(fisRow).setHeight((short) 900);
+                                    newStyle.setWrapText(true);
+                                }
+                                redFont.setBold(true);
+                                newStyle.setFont(redFont);
+                                cell.setCellStyle(newStyle);
+                                cell.setCellValue(title);
+                                break;
+                            }
+                        }
+                    }
 
                     try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
                         workbook.write(byteArrayOutputStream);

+ 122 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -51,6 +51,7 @@ import org.springblade.manager.feign.ContractClient;
 import org.springblade.manager.feign.ExcelTabClient;
 import org.springblade.manager.feign.TableFileClient;
 import org.springblade.manager.feign.WbsTreePrivateClient;
+import org.springblade.manager.vo.TrialTableDataInfo;
 import org.springblade.resource.entity.Attach;
 import org.springblade.resource.feign.CommonFileClient;
 import org.springblade.resource.feign.IOSSClient;
@@ -2400,4 +2401,125 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
             updateBatchById(trialSelfInspectionRecords);
         }
     }
+    //    @Override
+    public List<Map<String, Object>> getTrialTableData(List<Long> recordIds){
+        List<TrialSelfInspectionRecord> trialSelfInspectionRecords = this.listByIds(recordIds);
+        Map<String, Dict> map = iDictClient.getList("trial_detection_category").getData().stream().collect(Collectors.toMap(Dict::getDictKey, Function.identity()));
+        Map<String, Long> projectPositionMap = new HashMap<>();
+        Set<String> entrustIds = new HashSet<>();
+        StringBuilder sb = new StringBuilder();
+        trialSelfInspectionRecords.forEach(record -> {
+            //工程部位及用途名称
+            if (ObjectUtil.isNotEmpty(record.getProjectPosition())) {
+                List<String> ids = Func.toStrList(record.getProjectPosition()); //关联的工程部位ids
+                for (String id : ids) {
+                    projectPositionMap.put(id, record.getId());
+                }
+            }
+            sb.append(record.getId()).append(",");
+            if (record.getEntrustId() != null && record.getEntrustId() > 0) {
+                entrustIds.add(record.getEntrustId() + "");
+            }
+        });
+        Map<Long, List<String>> projectPositionGroupMap = new HashMap<>();
+        Map<String, Map<String, Object>> entrustMap = new HashMap<>();
+        Map<String, String> rawMaterialMap = new HashMap<>();
+        if (!projectPositionMap.isEmpty()) {
+            //查询工程部位节点名称信息
+            List<WbsTreeContract> result = baseMapper.selectWbsTreeContractListByPKeyIds(new ArrayList<>(projectPositionMap.keySet()));
+            projectPositionGroupMap = result.stream().collect(Collectors.groupingBy(item -> projectPositionMap.get(item.getPKeyId() + ""), Collectors.mapping(WbsTreeContract::getNodeName, Collectors.toList())));
+        }
+        if (!entrustIds.isEmpty()) {
+            List<Map<String, Object>> mapList = jdbcTemplate.queryForList("SELECT a.id, a.entrust_name,a.entrust_no,b.specification_number, b.specification_model from u_entrust_info a INNER JOIN u_trial_sample_info b on a.sample_id = b.id where a.is_deleted = 0 and a.id in ( "
+                    + String.join(",", entrustIds) + " )");
+            if (!mapList.isEmpty()) {
+                entrustMap = mapList.stream().collect(Collectors.toMap(m -> m.get("id") + "", m -> m));
+            }
+        }
+        if (sb.length() > 0) {
+            sb.deleteCharAt(sb.length() - 1);
+            //原材料检测报告ids
+            List<Map<String, Object>> mapList = jdbcTemplate.queryForList("SELECT a.self_id,c.production_certificate from u_trial_self_sample a left JOIN u_trial_sampling_record b on a.sampling_id = b.sample_info_id " +
+                    "left JOIN u_trial_material_mobilization c on b.mobilization_id = c.id where a.self_id in (" + sb + ")");
+            if (!mapList.isEmpty()) {
+                rawMaterialMap = mapList.stream().collect(Collectors.toMap(m -> m.get("self_id") + "", m -> m.get("production_certificate") == null ? "" : m.get("production_certificate") + "", (m, n) -> m));
+            }
+        }
+        List<Map<String, Object>> result = new ArrayList<>();
+        for (TrialSelfInspectionRecord record : trialSelfInspectionRecords) {
+            Map<String, Object> resultMap = new HashMap<>();
+            resultMap.put(TrialTableDataInfo.TrialTableElementEnum.RECORD_NO.getKey(), record.getRecordNo());
+            resultMap.put(TrialTableDataInfo.TrialTableElementEnum.REPORT_NO.getKey(), record.getReportNo());
+            resultMap.put(TrialTableDataInfo.TrialTableElementEnum.TRIAL_PROJECT_NAME.getKey(), record.getTrialProjectName());
+            resultMap.put(TrialTableDataInfo.TrialTableElementEnum.TASK_STATUS.getKey(), record.getTaskStatus());
+            resultMap.put(TrialTableDataInfo.TrialTableElementEnum.REPORT_DATE.getKey(), DateUtil.format(record.getReportDate(), "yyyy-MM-dd"));
+            resultMap.put(TrialTableDataInfo.TrialTableElementEnum.TRIAL_USER_NAME.getKey(), record.getTrialUserName());
+            resultMap.put(TrialTableDataInfo.TrialTableElementEnum.SPECIFICATION_MODEL.getKey(), record.getSpecificationModel());
+            resultMap.put(TrialTableDataInfo.TrialTableElementEnum.SAMPLING_LOCATION.getKey(), record.getSamplingLocation());
+
+            resultMap.put(TrialTableDataInfo.TrialTableElementEnum.CONTRACT_NAME.getKey(), record.getContractId());
+            resultMap.put(TrialTableDataInfo.TrialTableElementEnum.COMPANY.getKey(), record.getCompany());
+            resultMap.put(TrialTableDataInfo.TrialTableElementEnum.DETECTION_RESULT.getKey(), (new Integer(1)).equals(record.getDetectionResult()) ? "合格" : "不合格");
+
+            if (ObjectUtils.isNotEmpty(record.getDetectionCategory())) {
+                Dict dict = map.get(String.valueOf(record.getDetectionCategory()));
+                if (dict != null) {
+                    resultMap.put(TrialTableDataInfo.TrialTableElementEnum.DETECTION_CATEGORY.getKey(), dict.getDictValue());
+                }
+            }
+            //工程部位及用途名称
+            if (ObjectUtil.isNotEmpty(record.getProjectPosition())) {
+                List<String> projectPositionNames = projectPositionGroupMap.get(record.getId());
+                if (projectPositionNames != null) {
+                    String name = projectPositionNames.stream().findAny().orElse(null);
+                    if (projectPositionNames.size() > 1) {
+                        resultMap.put(TrialTableDataInfo.TrialTableElementEnum.PROJECT_POSITION.getKey(), name + "等" + projectPositionNames.size() + "个工程部位信息");
+                    } else {
+                        resultMap.put(TrialTableDataInfo.TrialTableElementEnum.PROJECT_POSITION.getKey(), name);
+                    }
+                }
+            }
+            //关联取样ids
+            String productionCertificate = rawMaterialMap.get(record.getId() + "");
+            if (productionCertificate != null) {
+                if (!productionCertificate.isEmpty()) {
+                    resultMap.put(TrialTableDataInfo.TrialTableElementEnum.IS_UPLOAD_CERTIFICATE.getKey(), "是");
+                } else {
+                    resultMap.put(TrialTableDataInfo.TrialTableElementEnum.IS_UPLOAD_CERTIFICATE.getKey(), "否");
+                }
+            }
+            //委托单名称 委托单编号
+            Map<String, Object> entrust = entrustMap.get(record.getEntrustId() + "");
+            if (entrust != null) {
+                resultMap.put(TrialTableDataInfo.TrialTableElementEnum.ENTRUST_NAME.getKey(), entrust.get("entrust_name") == null ? "" : entrust.get("entrust_name") + "");
+                resultMap.put(TrialTableDataInfo.TrialTableElementEnum.ENTRUST_NO.getKey(), entrust.get("entrust_no") == null ? "" : entrust.get("entrust_no") + "");
+                //材料id不为空
+                Object object = entrust.get("specification_number");
+                if (object != null) {
+                    resultMap.put(TrialTableDataInfo.TrialTableElementEnum.SPECIFICATION_NUMBER.getKey(), object);
+                }
+                Object object1 = entrust.get("specification_model");
+                if (object1 != null) {
+                    resultMap.put("specificationModel", object1);
+                }
+            }
+            if (record.getBaseInfo() != null && !record.getBaseInfo().isEmpty()) {
+                try {
+                    TrialSeleInspectionRecordBaseInfoDTO baseInfoDTO = JSON.parseObject(record.getBaseInfo(), TrialSeleInspectionRecordBaseInfoDTO.class);
+                    if (baseInfoDTO != null) {
+                        if (StringUtil.hasText(baseInfoDTO.getEntrustNo())) {
+                            resultMap.put("entrustNo",baseInfoDTO.getEntrustNo());
+                        }
+                        if (StringUtil.hasText(baseInfoDTO.getProjectPosition())) {
+                            resultMap.put("projectPosition",baseInfoDTO.getProjectPosition());
+                        }
+                    }
+                } catch (Exception e) {
+                    log.warn("JSON反序列化失败:" + record.getBaseInfo());
+                }
+            }
+            result.add(resultMap);
+        }
+        return result;
+    }
 }

+ 29 - 6
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/TrialSummaryClassificationConfigurationController.java

@@ -30,6 +30,7 @@ import org.springblade.manager.service.IWbsFormElementService;
 import org.springblade.manager.service.impl.WbsTreePrivateServiceImpl;
 import org.springblade.manager.vo.ExcelTabTreeVO;
 import org.springblade.manager.vo.SelectedTabVO;
+import org.springblade.manager.vo.TrialTableDataInfo;
 import org.springblade.manager.vo.TrialTreeVO;
 import org.springblade.system.cache.ParamCache;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
@@ -65,6 +66,9 @@ public class TrialSummaryClassificationConfigurationController extends BladeCont
     @ApiOperation(value = "新增或修改", notes = "传入TrialSummaryClassificationConfiguration对象")
     @RequestMapping(value = "/submit", method = RequestMethod.POST)
     public R<Object> submit(@Valid @RequestBody TrialSummaryClassificationConfiguration obj) {
+        if (obj == null || obj.getProjectType() == null) {
+            return R.fail("参数错误");
+        }
         return R.status(iTrialSummaryClassificationConfigurationService.submit(obj));
     }
 
@@ -139,7 +143,7 @@ public class TrialSummaryClassificationConfigurationController extends BladeCont
             if (file1.exists()) {
                 fileInputStream = new FileInputStream(file1);
             } else {
-                String path = sys_file_net_url + fileUrl.replaceAll("//", "/").replaceAll(file_path, "");
+                String path = sys_file_net_url + fileUrl.replaceAll("//", "/").replaceAll(file_path, "").replaceAll("/www/wwwroot/Users/hongchuangyanfa/Desktop/", "");
                 fileInputStream = CommonUtil.getOSSInputStream(path);
             }
             String htmlString = IoUtil.readToString(fileInputStream);
@@ -159,6 +163,7 @@ public class TrialSummaryClassificationConfigurationController extends BladeCont
     @RequestMapping(value = "/tab/list", method = RequestMethod.GET)
     public R<List<SelectedTabVO>> tabList(@RequestParam String classId) {
         TrialSummaryClassificationConfiguration trialSummaryClassificationConfiguration = iTrialSummaryClassificationConfigurationService.getById(classId);
+        List<SelectedTabVO> list = new ArrayList<>();
         if (trialSummaryClassificationConfiguration != null && ObjectUtil.isNotEmpty(trialSummaryClassificationConfiguration.getTrialTreeIds())) {
             List<WbsTreePrivate> query = jdbcTemplate.query("SELECT id,project_id,wbs_id,wbs_type FROM m_wbs_tree_private WHERE p_key_id in (" + trialSummaryClassificationConfiguration.getTrialTreeIds() + ")", new BeanPropertyRowMapper<>(WbsTreePrivate.class));
             List<Long> ids = query.stream().map(WbsTreePrivate::getId).collect(Collectors.toList());
@@ -171,7 +176,6 @@ public class TrialSummaryClassificationConfigurationController extends BladeCont
                         .eq(WbsTreePrivate::getWbsType, wbsType)
                         .eq(WbsTreePrivate::getType, 2)
                         .eq(WbsTreePrivate::getWbsId, wbsId));
-                List<SelectedTabVO> list = new ArrayList<>();
                 for (WbsTreePrivate wbsTreePrivate : wbsTreePrivates) {
                     SelectedTabVO vo = new SelectedTabVO();
                     vo.setPKeyId(wbsTreePrivate.getPKeyId());
@@ -180,16 +184,24 @@ public class TrialSummaryClassificationConfigurationController extends BladeCont
                     vo.setInitTableName(wbsTreePrivate.getInitTableName());
                     list.add(vo);
                 }
-                return R.data(list);
             }
         }
-        return null;
+        SelectedTabVO selectedTabVO = new SelectedTabVO();
+        selectedTabVO.setPKeyId(TrialTableDataInfo.LONG_ID);
+        selectedTabVO.setTabName(TrialTableDataInfo.TBN_CH);
+        selectedTabVO.setInitTableName(TrialTableDataInfo.TBN);
+        selectedTabVO.setInitTabId(TrialTableDataInfo.LONG_ID);
+        list.add(selectedTabVO);
+        return R.data(list);
     }
 
     @ApiOperationSupport(order = 11)
     @ApiOperation(value = "选择元素列表", notes = "传入/tab/list接口的initTabId")
     @RequestMapping(value = "/element/list", method = RequestMethod.GET)
     public R<List<WbsFormElement>> elementList(@RequestParam String id) {
+        if (TrialTableDataInfo.ID.equals( id)) {
+            return R.data(TrialTableDataInfo.getElementList());
+        }
         return R.data(wbsFormElementService.selectElementListByFid(id));
     }
 
@@ -202,6 +214,13 @@ public class TrialSummaryClassificationConfigurationController extends BladeCont
             String sql = "SELECT * FROM m_trial_summary_excel_tab_reflection WHERE excel_id = ? AND html_key_name = ?";
             TrialSummaryExcelTabReflection obj = jdbcTemplate.query(sql, new Object[]{classificationConfiguration.getExcelId(), keyName}, new BeanPropertyRowMapper<>(TrialSummaryExcelTabReflection.class)).stream().findAny().orElse(null);
             if (obj != null) {
+                if (TrialTableDataInfo.LONG_ID.equals(obj.getTrialTabId())) {
+                    Map<String, String> map = new HashMap<>();
+                    map.put("id", obj.getId().toString());
+                    map.put("tabName", TrialTableDataInfo.TBN_CH);
+                    map.put("elementName", TrialTableDataInfo.getElementName(obj.getElementKey()));
+                    return R.data(map);
+                }
                 WbsTreePrivate trialTab = wbsTreePrivateServiceImpl.getBaseMapper().getByPKeyId(obj.getTrialTabId());
                 WbsFormElement element = wbsFormElementService.getById(obj.getElementId());
                 if (trialTab != null && element != null) {
@@ -295,8 +314,12 @@ public class TrialSummaryClassificationConfigurationController extends BladeCont
                         map.put("id", obj.getId());
                         map.put("trialTabId", obj.getTrialTabId());
                         map.put("elementId", obj.getElementId());
-                        WbsFormElement orDefault = eleMap.getOrDefault(obj.getElementId(), null);
-                        map.put("elementValue", ObjectUtil.isNotEmpty(orDefault) ? orDefault.getEName() : null);
+                        if (TrialTableDataInfo.LONG_ID.equals(obj.getTrialTabId())) {
+                            map.put("elementValue", TrialTableDataInfo.getElementName(obj.getElementKey()));
+                        } else {
+                            WbsFormElement orDefault = eleMap.getOrDefault(obj.getElementId(), null);
+                            map.put("elementValue", ObjectUtil.isNotEmpty(orDefault) ? orDefault.getEName() : null);
+                        }
                         map.put("htmlKeyName", obj.getHtmlKeyName());
                         maps.add(map);
                     }