Browse Source

试验bug

liuyc 2 năm trước cách đây
mục cha
commit
3fa105314c

+ 52 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialContainerController.java

@@ -6,6 +6,8 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springblade.business.dto.TrialContainerClassificationDTO;
 import org.springblade.business.dto.TrialContainerDataDTO;
 import org.springblade.business.dto.TrialContainerVerificationDTO;
@@ -21,10 +23,14 @@ import org.springblade.core.tool.utils.Func;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URLEncoder;
 import java.util.HashMap;
 import java.util.List;
+import java.util.stream.Collectors;
 
 @RestController
 @AllArgsConstructor
@@ -119,5 +125,51 @@ public class TrialContainerController extends BladeController {
         return R.data(iTrialContainerClassificationService.dataVerificationNo(dto.getBean(), dto.getId(), dto.getContainerInitTabName()));
     }
 
+    @PostMapping("/data/download-template")
+    @ApiOperationSupport(order = 11)
+    @ApiOperation(value = "下载当前容器的excel模板", notes = "传入容器id")
+    public R<Object> downloadExcelTemplate(@RequestParam String id, HttpServletResponse response) throws IOException {
+        TrialContainerClassification objRoot = trialContainerClassificationMapper.selectById(id);
+        if (objRoot != null) {
+            List<TrialContainerClassification> filedList = trialContainerClassificationMapper.selectList(Wrappers.<TrialContainerClassification>lambdaQuery().eq(TrialContainerClassification::getContainerId, id));
+            if (filedList.size() > 0) {
+                List<String> fieldNames = filedList.stream().map(TrialContainerClassification::getFieldName).collect(Collectors.toList());
+                this.exportToExcelTemplate(objRoot.getContainerName(), fieldNames, response);
+                return R.success("导出成功");
+            } else {
+                return R.success("当前容器没有字段,请新增容器字段后再下载模板");
+            }
+        } else {
+            return R.success("请选择一个容器后再下载模板");
+        }
+    }
+
+    private void exportToExcelTemplate(String sheetName, List<String> fieldNames, HttpServletResponse response) throws IOException {
+        Workbook workbook = new XSSFWorkbook();
+        Sheet sheet = workbook.createSheet(sheetName);
+
+        Row titleRow = sheet.createRow(0);
+        CellStyle titleStyle = workbook.createCellStyle();
+        Font titleFont = workbook.createFont();
+        titleFont.setBold(true);
+        titleStyle.setFont(titleFont);
+
+        int colCount = fieldNames.size();
+        for (int i = 0; i < colCount; i++) {
+            Cell cell = titleRow.createCell(i);
+            cell.setCellValue(fieldNames.get(i));
+            cell.setCellStyle(titleStyle);
+        }
+
+        response.reset();
+        response.setContentType("application/octet-stream");
+        String fileName = URLEncoder.encode(sheetName + ".xlsx", "UTF-8");
+        response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\"");
+        OutputStream outputStream = response.getOutputStream();
+        workbook.write(outputStream);
+        outputStream.flush();
+        workbook.close();
+    }
+
 
 }

+ 7 - 17
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialDetectionController.java

@@ -161,25 +161,15 @@ public class TrialDetectionController extends BladeController {
         if (recordList.size() > 0) {
             return R.fail("只能删除未上报或已废除的试验记录信息,操作失败");
         }
-        //刪除按钮状态记录
-        String sql1 = "delete from u_trial_self_data_record where record_id in(" + ids + ")";
-        jdbcTemplate.execute(sql1);
 
-        //删除样品关联记录
-        String sql2 = "delete from u_trial_self_sample where self_id in(" + ids + ")";
-        jdbcTemplate.execute(sql2);
+        String sql = "delete from u_trial_self_data_record where record_id in(" + ids + ");" +
+                "delete from u_trial_self_sample where self_id in(" + ids + ");" +
+                "delete from u_trial_raw_material_self_record where self_record_id in(" + ids + ");" +
+                "delete from u_trial_self_quality_project where self_id in(" + ids + ");" +
+                "delete from u_trial_self_inspection_record where id in(" + ids + ");" +
+                "delete from u_information_query where wbs_id in(" + ids + ") and type = 2;";
+        jdbcTemplate.execute(sql);
 
-        //删除工程部位关联记录
-        String sql3 = "delete from u_trial_raw_material_self_record where self_record_id in(" + ids + ")";
-        jdbcTemplate.execute(sql3);
-
-        //删除原材料检测报告关联记录
-        String sql4 = "delete from u_trial_self_quality_project where self_id in(" + ids + ")";
-        jdbcTemplate.execute(sql4);
-
-        //删除试验记录
-        String sql5 = "delete from u_trial_self_inspection_record where id in(" + ids + ")";
-        jdbcTemplate.execute(sql5);
         return R.status(true);
     }
 

+ 2 - 2
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialSelfInspectionRecordMapper.java

@@ -10,7 +10,7 @@ import java.util.List;
 
 public interface TrialSelfInspectionRecordMapper extends BaseMapper<TrialSelfInspectionRecord> {
 
-    List<TrialSelfInspectionRecord> selectAll(Long nodeId, Long contractId);
+    List<TrialSelfInspectionRecord> selectAll(Long nodeId, Long contractId, Integer type);
 
     void saveSelfSample(Long id, Long selfId, String samplingId);
 
@@ -30,7 +30,7 @@ public interface TrialSelfInspectionRecordMapper extends BaseMapper<TrialSelfIns
 
     String selectInformationQuery(String id, String contractId, String classify);
 
-    void updateInformationQuery(Long id, Long contractId,String link);
+    void updateInformationQuery(Long id, Long contractId, String link);
 
     void deleteSeletedStatusByNodeId(String nodeId, Integer type, String recordId);
 

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialSelfInspectionRecordMapper.xml

@@ -64,7 +64,7 @@
     </delete>
 
     <select id="selectAll" resultType="org.springblade.business.entity.TrialSelfInspectionRecord">
-        select record_no,report_no from u_trial_self_inspection_record where node_id = #{nodeId} and contract_id = #{contractId} and is_deleted = 0
+        select record_no,report_no from u_trial_self_inspection_record where node_id = #{nodeId} and contract_id = #{contractId} and is_deleted = 0 and type = #{type}
     </select>
 
     <select id="selectSelfSampleRecord" resultType="java.lang.String">

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

@@ -109,7 +109,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
             Map<String, Dict> map = iDictClient.getList("trial_detection_category").getData().stream().collect(Collectors.toMap(Dict::getDictKey, Function.identity()));
 
             for (TrialSelfInspectionRecordVO record : records) {
-                record.setDetectionResultName((new Integer(1)).equals(record.getDetectionResult()) ? "合格" : "");
+                record.setDetectionResultName((new Integer(1)).equals(record.getDetectionResult()) ? "合格" : "不合格");
                 if (StringUtils.isNotEmpty(record.getDetectionResultName())) {
                     record.setDetectionResult(1);
                 } else {
@@ -1054,7 +1054,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
 
     private void buildNumber(TrialSelfInspectionRecordDTO dto) {
         StringSPUtils spUtils = new StringSPUtils();
-        List<TrialSelfInspectionRecord> result = baseMapper.selectAll(dto.getNodeId(), dto.getContractId());
+        List<TrialSelfInspectionRecord> result = baseMapper.selectAll(dto.getNodeId(), dto.getContractId(), dto.getType());
         List<TrialSelfInspectionRecord> trialSelfInspectionRecords = result.stream().filter(Objects::nonNull).collect(Collectors.toList());
 
         //两种类型同时生成

+ 5 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/WbsTreePrivateClientImpl.java

@@ -150,6 +150,11 @@ public class WbsTreePrivateClientImpl implements WbsTreePrivateClient {
             }
             if (newFiles.size() > 0) {
                 tableFileClient.saveBatch(newFiles);
+
+                //修改文件上传按钮状态
+                String sqlAdd = "insert into u_trial_self_data_record(id,record_id,tab_id,is_buss_show,is_tab_pdf,is_tab_file_type,pdf_url) values" +
+                        "(" + SnowFlakeUtil.getId() + "," + id + "," + newPkId + "," + 1 + "," + 1 + "," + 2 + ",null)";
+                jdbcTemplate.execute(sqlAdd);
             }
             if (ObjectUtils.isNotEmpty(wbsTreePrivate)) {
                 wbsTreePrivateService.save(wbsTreePrivate);

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

@@ -508,7 +508,9 @@
                   and is_deleted = 0
                   and project_id = #{projectId}
                   and contract_id = #{contractId}
-                  and wbs_id = #{wbsId})                                                        AS "status"
+                  and wbs_id = #{wbsId}
+                  and type = 1
+                   )                                                        AS "status"
         FROM m_wbs_tree_contract d
         WHERE d.is_deleted = 0
           AND d.status = 1

+ 70 - 64
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -1849,37 +1849,55 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                         }
                     }
                 }
-            }
 
-            if (dataIn.size() >= 1) {
-                Map<String, Object> mysqlData = dataIn.get(0);
-                for (String key : mysqlData.keySet()) {
-                    String tabVal = mysqlData.get(key) + "";
+                if (dataIn.size() >= 1) {
+                    Map<String, Object> mysqlData = dataIn.get(0);
+                    for (String key : mysqlData.keySet()) {
+                        String tabVal = mysqlData.get(key) + "";
 
-                    // 时间段处理
-                    if (StringUtils.isNotEmpty(tabVal) && !tabVal.equals("null")) {
-                        if (tabVal.contains("T") && tabVal.contains(".000Z]")) {
-                            String[] tabData = tabVal.split("_\\^_");
+                        if (tabVal.contains("BG-") || tabVal.contains("JL-")) {
+                            //重新生成自己的编号,不引用旧编号
+                            continue;
+                        }
 
-                            if (reData.containsKey("pickerKey")) {
-                                String pickerKey = reData.get("pickerKey") + "," + key + "__" + tabData[1];
-                                reData.put("pickerKey", pickerKey);
-                            } else {
-                                reData.put("pickerKey", key + "__" + tabData[1]);
-                            }
+                        // 时间段处理
+                        if (StringUtils.isNotEmpty(tabVal) && !tabVal.equals("null")) {
+                            if (tabVal.contains("T") && tabVal.contains(".000Z]")) {
+                                String[] tabData = tabVal.split("_\\^_");
 
-                            String sql = tabData[0];
-                            sql = sql.replaceAll("\\[", "['");
-                            sql = sql.replaceAll("]", "']");
-                            sql = sql.replaceAll("000Z,", "000Z',");
-                            sql = sql.replaceAll(", 20", ", '20");
-                            //   sql = sql.replaceAll("'", "");
-                            if (StringUtils.isNotEmpty(tabData[0])) {
-                                reData.put(key + "__" + tabData[1], sql);
-                            }
-                        } else if (tabVal.indexOf("T") >= 0 && tabVal.indexOf(".000Z") >= 0) {//时间
-                            // 时间和字符串合作
-                            if (tabVal.indexOf("☆") >= 0) {
+                                if (reData.containsKey("pickerKey")) {
+                                    String pickerKey = reData.get("pickerKey") + "," + key + "__" + tabData[1];
+                                    reData.put("pickerKey", pickerKey);
+                                } else {
+                                    reData.put("pickerKey", key + "__" + tabData[1]);
+                                }
+
+                                String sql = tabData[0];
+                                sql = sql.replaceAll("\\[", "['");
+                                sql = sql.replaceAll("]", "']");
+                                sql = sql.replaceAll("000Z,", "000Z',");
+                                sql = sql.replaceAll(", 20", ", '20");
+                                //   sql = sql.replaceAll("'", "");
+                                if (StringUtils.isNotEmpty(tabData[0])) {
+                                    reData.put(key + "__" + tabData[1], sql);
+                                }
+                            } else if (tabVal.indexOf("T") >= 0 && tabVal.indexOf(".000Z") >= 0) {//时间
+                                // 时间和字符串合作
+                                if (tabVal.indexOf("☆") >= 0) {
+                                    String[] mysql = tabVal.split("☆");
+                                    for (String data : mysql) {
+                                        String[] tabData = data.split("_\\^_");
+                                        if (StringUtils.isNotEmpty(tabData[0])) {
+                                            reData.put(key + "__" + tabData[1], tabData[0]);
+                                        }
+                                    }
+                                } else {
+                                    String[] tabData = tabVal.split("_\\^_");
+                                    if (StringUtils.isNotEmpty(tabData[0])) {
+                                        reData.put(key + "__" + tabData[1], tabData[0]);
+                                    }
+                                }
+                            } else if (tabVal.indexOf("☆") >= 0) {
                                 String[] mysql = tabVal.split("☆");
                                 for (String data : mysql) {
                                     String[] tabData = data.split("_\\^_");
@@ -1887,38 +1905,23 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                                         reData.put(key + "__" + tabData[1], tabData[0]);
                                     }
                                 }
-                            } else {
+                            } else if (tabVal.indexOf("_^_") >= 0) {
                                 String[] tabData = tabVal.split("_\\^_");
                                 if (StringUtils.isNotEmpty(tabData[0])) {
-                                    reData.put(key + "__" + tabData[1], tabData[0]);
-                                }
-                            }
-                        } else if (tabVal.indexOf("☆") >= 0) {
-                            String[] mysql = tabVal.split("☆");
-                            for (String data : mysql) {
-                                String[] tabData = data.split("_\\^_");
-                                if (StringUtils.isNotEmpty(tabData[0])) {
-                                    reData.put(key + "__" + tabData[1], tabData[0]);
-                                }
-                            }
-                        } else if (tabVal.indexOf("_^_") >= 0) {
-                            String[] tabData = tabVal.split("_\\^_");
-                            if (StringUtils.isNotEmpty(tabData[0])) {
-                                if (tabVal.contains("[") && tabVal.contains("年")) {
-                                    String[] strings = StringUtils.strip(tabData[0], "[]").split(",");
-                                    reData.put(key + "__" + tabData[1], strings);
-                                } else {
-                                    reData.put(key + "__" + tabData[1], tabData[0]);
+                                    if (tabVal.contains("[") && tabVal.contains("年")) {
+                                        String[] strings = StringUtils.strip(tabData[0], "[]").split(",");
+                                        reData.put(key + "__" + tabData[1], strings);
+                                    } else {
+                                        reData.put(key + "__" + tabData[1], tabData[0]);
+                                    }
                                 }
+                            } else {
+                                reData.put(key, tabVal);
                             }
-                        } else {
-                            reData.put(key, tabVal);
                         }
                     }
                 }
             }
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -1987,15 +1990,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             elementMap = jdbcTemplate.query(eleSql, new BeanPropertyRowMapper<>(WbsFormElement.class)).stream().collect(Collectors.toMap(WbsFormElement::getEKey, Function.identity()));
         }
 
-        // 匹配关联
-        try {
-            File file1 = ResourceUtil.getFile(wbsTreePrivate.getHtmlUrl());
-            String htmlString = IoUtil.readToString(new FileInputStream(file1));
-            Document doc = Jsoup.parse(htmlString);
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
-        }
-
         if (dataIn.size() >= 1) {
             Map<String, Object> mysqlData = dataIn.get(0);
             for (String key : mysqlData.keySet()) {
@@ -2275,12 +2269,24 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                                                 myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]));
                                             }
                                         }
+
+                                        if (myData.contains("lang.String")) {
+                                            Object obj = DataInfo.get(val);
+                                            if (obj instanceof String[]) {
+                                                String[] dataDate = (String[]) obj;
+                                                myData = dataDate[0] + "-" + dataDate[1].trim();
+                                            }
+                                        }
+
                                         //https:bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload/20220819/b53cb6700db369381e3b03d7737bcdec.jpg__16_1
-                                        if (myData.contains("https") && myData.contains("aliyuncs")) {
+                                        //http:bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload/20220819/b53cb6700db369381e3b03d7737bcdec.jpg__16_1 可能是http
+                                        if (myData.contains("http") && myData.contains("aliyuncs")) {
                                             InputStream imageIn = CommonUtil.getOSSInputStream(myData);
-                                            byte[] bytes = IOUtils.toByteArray(imageIn);
+                                            byte[] byteNew = IOUtils.toByteArray(imageIn);
+                                            byte[] bytesNew = CommonUtil.compressImage(byteNew);
+
                                             // 这里根据实际需求选择图片类型
-                                            int pictureIdx = workbook.addPicture(bytes, 6);
+                                            int pictureIdx = workbook.addPicture(bytesNew, 6);
 
                                             CreationHelper helper = workbook.getCreationHelper();
                                             ClientAnchor anchor = helper.createClientAnchor();
@@ -2288,7 +2294,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                                             anchor.setCol2(x2);
                                             anchor.setRow1(y1); // param2是行号
                                             anchor.setRow2(y2); // param2是行号
-                                            //
+
                                             Drawing<?> drawing = sheet.createDrawingPatriarch();
                                             anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);
                                             // 插入图片