Browse Source

委托单页面填报表单信息的页面材料信息基本数据回显

DengLinLang 5 months ago
parent
commit
b153e26351

+ 2 - 7
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java

@@ -72,12 +72,10 @@ import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
-import javax.annotation.Resource;
 import javax.imageio.ImageIO;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
@@ -93,10 +91,7 @@ import java.nio.file.StandardCopyOption;
 import java.text.SimpleDateFormat;
 import java.util.List;
 import java.util.*;
-import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -4091,9 +4086,9 @@ public class ExcelTabController extends BladeController {
             @ApiImplicitParam(name = "id", value = "记录id-当做groupId", required = true),
             @ApiImplicitParam(name = "contractId", value = "合同段id", required = true)
     })
-    public R<List<Map<String, Object>>> getBussDataInfoTrialentrust(Long id, Long pkeyId, Long contractId) {
+    public R<List<Map<String, Object>>> getBussDataInfoTrialentrust(Long id, Long pkeyId, Long contractId, Long sampleId) {
 
-        List<Map<String, Object>> bussDataInfoTrial = excelTabService.getBussDataInfoTrialentrust(id, pkeyId, contractId);
+        List<Map<String, Object>> bussDataInfoTrial = excelTabService.getBussDataInfoTrialentrust(id, pkeyId, contractId,sampleId);
         return R.data(bussDataInfoTrial);
     }
 

+ 7 - 9
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IExcelTabService.java

@@ -17,25 +17,23 @@
 package org.springblade.manager.service;
 
 import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.jsoup.nodes.Document;
 import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
+import org.springblade.core.mp.base.BaseService;
 import org.springblade.core.tool.api.R;
 import org.springblade.manager.bean.TableInfo;
-import org.springblade.manager.entity.*;
+import org.springblade.manager.entity.ExcelEditCallback;
+import org.springblade.manager.entity.ExcelTab;
+import org.springblade.manager.entity.WbsFormElement;
+import org.springblade.manager.entity.WbsTreeContract;
 import org.springblade.manager.enums.ExecuteType;
 import org.springblade.manager.vo.ExceTabTreVO;
 import org.springblade.manager.vo.ExcelTabVO;
-import org.springblade.core.mp.base.BaseService;
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springblade.manager.vo.ExcelTabWbsTypeVO;
 import org.springblade.manager.vo.WbsTreeVO;
-import org.springframework.web.bind.annotation.RequestParam;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import java.io.FileNotFoundException;
-import java.io.IOException;
 import java.sql.SQLException;
 import java.util.List;
 import java.util.Map;
@@ -210,5 +208,5 @@ public interface IExcelTabService extends BaseService<ExcelTab> {
      * @param contractId
      * @return
      */
-    List<Map<String, Object>> getBussDataInfoTrialentrust(Long id, Long pkeyId, Long contractId);
+    List<Map<String, Object>> getBussDataInfoTrialentrust(Long id, Long pkeyId, Long contractId, Long sampleId);
 }

+ 87 - 27
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -2,7 +2,6 @@ package org.springblade.manager.service.impl;
 
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.StopWatch;
-import org.springblade.core.mp.support.Query;
 import cn.hutool.log.StaticLog;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
@@ -15,33 +14,26 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.mixsmart.utils.FormulaUtils;
 import com.mixsmart.utils.ListUtils;
 import com.mixsmart.utils.RegexUtils;
-import com.spire.pdf.PdfDocument;
 import com.spire.xls.FileFormat;
-import com.spire.xls.Worksheet;
 import lombok.AllArgsConstructor;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.Font;
 import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
+import org.jsoup.nodes.Node;
 import org.jsoup.select.Elements;
 import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
-import org.springblade.business.entity.ContractLog;
-import org.springblade.business.entity.InformationQuery;
-import org.springblade.business.entity.TrialSelfInspectionRecord;
+import org.springblade.business.entity.*;
 import org.springblade.business.feign.ContractLogClient;
 import org.springblade.business.feign.InformationQueryClient;
 import org.springblade.business.feign.OperationLogClient;
-import org.springblade.business.feign.TrialSelfInspectionRecordClient;
 import org.springblade.business.vo.SaveContractLogVO;
 import org.springblade.common.constant.CommonConstant;
 import org.springblade.common.utils.CommonUtil;
@@ -50,6 +42,7 @@ import org.springblade.common.vo.DataVO;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
 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.tool.api.R;
@@ -66,14 +59,13 @@ import org.springblade.manager.formula.NodeTable;
 import org.springblade.manager.formula.impl.TableElementConverter;
 import org.springblade.manager.mapper.ExcelTabMapper;
 import org.springblade.manager.service.*;
-import org.springblade.manager.utils.ExcelInfoUtils;
 import org.springblade.manager.utils.FileUtils;
 import org.springblade.manager.utils.PdfAddimgUtil;
 import org.springblade.manager.vo.*;
 import org.springblade.resource.feign.NewIOSSClient;
 import org.springblade.system.cache.ParamCache;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.dao.DataAccessException;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
@@ -81,18 +73,13 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.TransactionDefinition;
 import org.springframework.transaction.TransactionStatus;
-import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.support.DefaultTransactionDefinition;
 
-import java.awt.geom.Rectangle2D;
 import java.io.*;
-import java.net.URL;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.List;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentSkipListMap;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Function;
@@ -4326,10 +4313,10 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
 
 
     /**
-     * 试验 委托单获取填报信息
+     * 试验 委托单获取填报信息  groupId和sampleId1必须传其中一个
      */
     @Override
-    public List<Map<String, Object>> getBussDataInfoTrialentrust(Long groupId, Long pkeyId, Long contractId) {
+    public List<Map<String, Object>> getBussDataInfoTrialentrust(Long groupId, Long pkeyId, Long contractId,Long sampleId1) {
         String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
         String sys_file_net_url = ParamCache.getValue(CommonConstant.SYS_FILE_NET_URL);
         List<Map<String, Object>> list = new ArrayList<>();
@@ -4355,6 +4342,10 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         //获取引用数据信息
         String loadDataId = "";
         String sampleId = "";
+        if(groupId == null){
+            sampleId = sampleId1.toString();
+        }
+
         try {
             String sqlQuery = "select * from u_trial_self_data_record where record_id = " + groupId + " and tab_id = " + pkeyId;
             List<Map<String, Object>> stringObjectMap = jdbcTemplate.queryForList(sqlQuery);
@@ -4362,10 +4353,12 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 loadDataId = stringObjectMap.get(0).get("load_data_id") + "";
             }
 
-            String samQuery = "SELECT * from u_entrust_info where id=" + groupId + " ";
-            List<Map<String, Object>> strbjectMap = jdbcTemplate.queryForList(samQuery);
-            if (strbjectMap != null && strbjectMap.size() >= 1) {
-                sampleId = strbjectMap.get(0).get("sample_id") + "";
+            if(groupId !=null){
+                String samQuery = "SELECT * from u_entrust_info where id=" + groupId + " ";
+                List<Map<String, Object>> strbjectMap = jdbcTemplate.queryForList(samQuery);
+                if (strbjectMap != null && strbjectMap.size() >= 1) {
+                    sampleId = strbjectMap.get(0).get("sample_id") + "";
+                }
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -4374,8 +4367,16 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             reData.put("loadDataId", loadDataId);
             reData.put("sampleId", sampleId);
         }
-
-
+        String querySql1 = "select * from u_trial_sample_info where id=" + sampleId ;
+        TrialSampleInfo sampleInfo = jdbcTemplate.queryForObject(querySql1, new BeanPropertyRowMapper<>(TrialSampleInfo.class));
+        //用sampleId查询出关联的材料对象
+        String querySql2 = "select * from u_trial_material_mobilization where id =(select mobilization_id from u_trial_sampling_record where sample_info_id = "+sampleId+") ";
+        TrialMaterialMobilization trialMaterialMobilization = null;
+        try {
+            trialMaterialMobilization = jdbcTemplate.queryForObject(querySql2, new BeanPropertyRowMapper<>(TrialMaterialMobilization.class));
+        } catch (DataAccessException e) {
+            trialMaterialMobilization = null;
+        }
         //实体数据
         String querySql = "select * from " + wbsTreePrivate.getInitTableName() + " where p_key_id=" + pkeyId + " and group_id = " + groupId;
         List<Map<String, Object>> dataIn = jdbcTemplate.queryForList(querySql);
@@ -4395,8 +4396,8 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
             htmlString = htmlString.replaceAll("title", "titlexx");
             Document doc = Jsoup.parse(htmlString);
-
-
+            //通过html获取页面上的key值 返回key值对应的数据
+            setBasicFormData(doc, reData, sampleInfo, trialMaterialMobilization);
             if (dataIn.size() >= 1) {
                 Map<String, Object> mysqlData = dataIn.get(0);
                 for (String key : mysqlData.keySet()) {
@@ -4494,4 +4495,63 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         return list;
     }
 
+    private static void setBasicFormData(Document doc, Map<String, Object> reData, TrialSampleInfo sampleInfo ,TrialMaterialMobilization trialMaterialMobilization) {
+//        //样品编号
+//        String specificationNumber = sampleInfo.getSpecificationNumber();
+//        Elements specificationNumberElements = doc.select("[placeholderxx=样品编号]");
+//        if (!specificationNumberElements.isEmpty()) {
+//            Element textareaElement = specificationNumberElements.first();
+//            String id = textareaElement.attr("id");
+//            reData.put(id, specificationNumber);
+//        } else {
+//            throw new RuntimeException("没有找到[placeholderxx=样品编号]的元素");
+//        }
+//        //取样地点
+//        String samplingLocation = sampleInfo.getSamplingLocation();
+//        Elements samplingLocationElements = doc.select("[placeholderxx=取样地点]");
+//        if (!samplingLocationElements.isEmpty()) {
+//            Element textareaElement = samplingLocationElements.first();
+//            String id = textareaElement.attr("id");
+//            reData.put(id, samplingLocation);
+//        } else {
+//            throw new RuntimeException("没有找到[placeholderxx=取样地点]的元素");
+//        }
+        setFirstData(doc,"样品编号",sampleInfo.getSpecificationNumber(),reData);
+        setFirstData(doc,"取样地点",sampleInfo.getSamplingLocation(),reData);
+        setFirstData(doc,"取样时间",sampleInfo.getSamplingDate(),reData);
+        setFirstData(doc,"试样名称",sampleInfo.getMaterialName(),reData);
+        setFirstData(doc,"规格 型号",sampleInfo.getSpecificationModel(),reData);
+        setFirstData(doc,"试样 数量",sampleInfo.getMaterialCount(),reData);
+        if(trialMaterialMobilization != null){
+            setFirstData(doc,"生产厂家",trialMaterialMobilization.getPlaceOfProduction(),reData);
+        }
+        String representativeCount = sampleInfo.getRepresentativeCount();
+        Date mobilizationDate = sampleInfo.getMobilizationDate();
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
+        String format = simpleDateFormat.format(mobilizationDate);
+        setFirstData(doc,"批号",sampleInfo.getBatchNumber(),reData);
+        setFirstData(doc,"拟用结构部 位",sampleInfo.getProposedPosition(),reData);
+        setFirstData(doc,"进场日期代表数量",format+representativeCount,reData);
+    }
+    private static void setFirstData(Document doc, String elementValue,Object value,Map<String, Object> reData) {
+
+        Elements select = doc.select("[placeholderxx=" + elementValue + "]");
+        if (!select.isEmpty()) {
+            Element textareaElement = select.first();
+            String id = textareaElement.attr("id");
+            reData.put(id, value);
+        } else {
+            if(elementValue.equals("进场日期代表数量")){
+                Elements select1 = doc.select("[titlexx=\"进场日期/ 代表数量\"]");
+                Element textareaElement = select1.first();
+                List<Node> nodes = textareaElement.childNodes();
+                Node node = nodes.get(1);
+                String id = node.attributes().get("id");
+                reData.put(id, value);
+            }else {
+                System.out.println("没有找到[" + elementValue + "]的元素");
+            }
+        }
+    }
+
 }