liuyc 2 years ago
parent
commit
d5337baa46

+ 6 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialLaboratoryUserArchives.java

@@ -18,6 +18,12 @@ import java.util.Date;
 public class TrialLaboratoryUserArchives extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
+    /**
+     * 合同段id
+     */
+    @ApiModelProperty("合同段id")
+    private Long contractId;
+
     /**
      * 姓名
      */

+ 4 - 0
blade-service/blade-business/pom.xml

@@ -144,6 +144,10 @@
             <version>2.9.1.RELEASE</version>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>org.jsoup</groupId>
+            <artifactId>jsoup</artifactId>
+        </dependency>
 
     </dependencies>
 

+ 5 - 6
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialDetectionController.java

@@ -347,13 +347,12 @@ public class TrialDetectionController extends BladeController {
         return R.fail(200, "未查询到数据");
     }
 
-    @PostMapping("/self/record-sample/submit")
+    @PostMapping("/self/record-sample/getData")
     @ApiOperationSupport(order = 27)
-    @ApiOperation(value = "自检记录关联取样信息保存", notes = "传入RecordSampleSubmitDTO")
-    public R<Object> recordSampleSubmit(@Valid @RequestBody RecordSampleSubmitDTO dto) {
-        //TODO 已剥离,融合到自检记录保存中
-        //return R.status(iTrialSelfInspectionRecordService.recordSampleSubmit(dto));
-        return R.status(true);
+    @ApiOperation(value = "获取关联取样信息对应在表中的Data与Key", notes = "传入tabPKeyId、样品sampleIds")
+    public R<Map<String, String>> getRecordSampleData(String tabPKeyId, String sampleIds) {
+        Map<String, String> result = iTrialDetectionDataService.getRecordSampleData(tabPKeyId, sampleIds);
+        return R.data(result);
     }
 
 }

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialMaterialController.java

@@ -58,7 +58,7 @@ public class TrialMaterialController extends BladeController {
     @PostMapping("/mobilization/upload-file")
     @ApiOperationSupport(order = 1)
     @ApiOperation(value = "附件上传", notes = "传入材料id、type、url地址")
-    public R<Object> uploadFile(@RequestParam String id, Integer type, String url) {
+    public R<Object> uploadFiles(@RequestParam("id") String id,@RequestParam("type") Integer type,@RequestParam("url") String url) {
         return R.data(iTrialMaterialMobilizationService.uploadFile(id, type, url));
     }
 

+ 4 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialDetectionDataService.java

@@ -7,6 +7,8 @@ import org.springblade.business.entity.TrialDetectionData;
 import org.springblade.business.vo.TrialDetectionDataVO;
 import org.springblade.core.mp.base.BaseService;
 
+import java.util.Map;
+
 public interface ITrialDetectionDataService extends BaseService<TrialDetectionData> {
 
     TrialDetectionData dataDetail(Long id);
@@ -17,4 +19,6 @@ public interface ITrialDetectionDataService extends BaseService<TrialDetectionDa
 
     boolean dataCopy(TrialDetectionDataDTO dto);
 
+    Map<String, String> getRecordSampleData(String tabPKeyId,String sampleIds);
+
 }

+ 0 - 2
blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialSelfInspectionRecordService.java

@@ -31,10 +31,8 @@ public interface ITrialSelfInspectionRecordService extends BaseService<TrialSelf
 
     String selfPrintNullPdf(String ids) throws Exception;
 
-    @Async
     void updateTrialSelfInspectionRecordStatus(String pdfUrlEVisa, TaskApprovalVO obj) throws FileNotFoundException;
 
-    @Async
     void updateTrialSelfInspectionRecordStatusFC(TaskApprovalVO obj);
 
     String addBussFile(MultipartFile file, Long pkeyId, String nodeId, String contractId, String projectId, String classify, String id, String tableType) throws Exception;

+ 130 - 7
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialDetectionDataServiceImpl.java

@@ -2,36 +2,56 @@ package org.springblade.business.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 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 lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.time.DateUtils;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
 import org.springblade.business.dto.TrialDetectionDataDTO;
 import org.springblade.business.dto.TrialDetectionDataPageDTO;
 import org.springblade.business.entity.TrialDetectionData;
+import org.springblade.business.entity.TrialSampleInfo;
+import org.springblade.business.entity.TrialSelfInspectionRecord;
 import org.springblade.business.mapper.TrialDetectionDataMapper;
 import org.springblade.business.mapper.TrialSelfInspectionRecordMapper;
 import org.springblade.business.service.ITrialDetectionDataService;
 import org.springblade.business.vo.TrialDetectionDataVO;
+import org.springblade.business.vo.TrialSelfSample;
 import org.springblade.common.utils.SnowFlakeUtil;
+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.utils.PageUtil;
-import org.springblade.core.tool.utils.BeanUtil;
-import org.springblade.core.tool.utils.DateUtil;
-import org.springblade.core.tool.utils.Func;
-import org.springblade.core.tool.utils.ObjectUtil;
+import org.springblade.core.tool.utils.*;
+import org.springblade.manager.entity.TextdictInfo;
+import org.springblade.manager.entity.WbsFormElement;
+import org.springblade.manager.entity.WbsTreePrivate;
+import org.springblade.manager.feign.WbsTreeContractClient;
+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.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 @Service
 @AllArgsConstructor
 public class TrialDetectionDataServiceImpl extends BaseServiceImpl<TrialDetectionDataMapper, TrialDetectionData> implements ITrialDetectionDataService {
 
     private final TrialSelfInspectionRecordMapper inspectionRecordMapper;
-
+    private final JdbcTemplate jdbcTemplate;
 
     @Override
     public TrialDetectionData dataDetail(Long id) {
@@ -40,6 +60,34 @@ public class TrialDetectionDataServiceImpl extends BaseServiceImpl<TrialDetectio
 
     @Override
     public boolean dataSubmit(TrialDetectionData obj) {
+        List<TrialDetectionData> trialDetectionData = baseMapper.selectList(Wrappers.<TrialDetectionData>lambdaQuery()
+                .select(TrialDetectionData::getId)
+                .isNotNull(TrialDetectionData::getReportNo)
+                .eq(TrialDetectionData::getReportNo, obj.getReportNo()));
+        if (ObjectUtil.isEmpty(obj.getId()) && trialDetectionData.size() > 0) {
+            throw new ServiceException("报告编号已存在,请重新填写");
+        }
+        if (ObjectUtil.isNotEmpty(obj.getId()) && trialDetectionData.size() > 0) {
+            TrialDetectionData data = trialDetectionData.stream().findAny().orElse(null);
+            if (!obj.getId().equals(data.getId())) {
+                throw new ServiceException("报告编号已存在,请重新填写");
+            }
+        }
+
+        List<TrialDetectionData> trialDetectionData2 = baseMapper.selectList(Wrappers.<TrialDetectionData>lambdaQuery()
+                .select(TrialDetectionData::getId)
+                .isNotNull(TrialDetectionData::getEntrustNo)
+                .eq(TrialDetectionData::getEntrustNo, obj.getEntrustNo()));
+        if (ObjectUtil.isEmpty(obj.getId()) && trialDetectionData2.size() > 0) {
+            throw new ServiceException("委托编号已存在,请重新填写");
+        }
+        if (ObjectUtil.isNotEmpty(obj.getId()) && trialDetectionData2.size() > 0) {
+            TrialDetectionData data = trialDetectionData2.stream().findAny().orElse(null);
+            if (!obj.getId().equals(data.getId())) {
+                throw new ServiceException("委托编号已存在,请重新填写");
+            }
+        }
+
         return this.saveOrUpdate(obj);
     }
 
@@ -60,7 +108,7 @@ public class TrialDetectionDataServiceImpl extends BaseServiceImpl<TrialDetectio
         if (StringUtils.isNotEmpty(dto.getQueryValue())) {
             queryWrapper.lambda().and(wrapper -> wrapper.like(TrialDetectionData::getEntrustNo, dto.getQueryValue()).or().like(TrialDetectionData::getReportNo, dto.getQueryValue()));
         }
-        IPage<TrialDetectionData> pages = this.page(page, queryWrapper.lambda().orderBy(true, true, TrialDetectionData::getCreateTime));
+        IPage<TrialDetectionData> pages = this.page(page, queryWrapper.lambda().orderBy(true, false, TrialDetectionData::getCreateTime));
         List<TrialDetectionDataVO> trialDetectionDataVOS = BeanUtil.copyProperties(pages.getRecords(), TrialDetectionDataVO.class);
 
         if (ObjectUtil.isNotEmpty(dto.getQualityTestPKeyId())) {
@@ -100,7 +148,7 @@ public class TrialDetectionDataServiceImpl extends BaseServiceImpl<TrialDetectio
         } else {
             //单条复制编辑新增保存
             TrialDetectionData obj = BeanUtil.copyProperties(dto, TrialDetectionData.class);
-            if (obj != null){
+            if (obj != null) {
                 obj.setId(SnowFlakeUtil.getId());
                 obj.setEntrustNo(String.valueOf(SnowFlakeUtil.getId()));
                 obj.setReportNo(String.valueOf(SnowFlakeUtil.getId()));
@@ -110,6 +158,81 @@ public class TrialDetectionDataServiceImpl extends BaseServiceImpl<TrialDetectio
         return true;
     }
 
+    @Override
+    public Map<String, String> getRecordSampleData(String tabPKeyId, String sampleIds) {
+        Map<String, String> resultMap = new HashMap<>();
+        //获取表中的数据信息Data、以及对应的Key值
+        WbsTreePrivate wbsTreePrivate = jdbcTemplate.query("select init_table_name,html_url,p_key_id from m_wbs_tree_private where p_key_id =" + tabPKeyId, new BeanPropertyRowMapper<>(WbsTreePrivate.class)).stream().findAny().orElse(null);
+        if (wbsTreePrivate == null) {
+            return null;
+        }
+        if (wbsTreePrivate.getHtmlUrl() == null) {
+            return null;
+        }
+
+        // 匹配关联
+        try {
+            File file1 = ResourceUtil.getFile(wbsTreePrivate.getHtmlUrl());
+            String htmlString = IoUtil.readToString(new FileInputStream(file1));
+            Document doc = Jsoup.parse(htmlString);
+            Elements ypName = doc.select("el-input[placeholder~=样品名称.*]");
+            Elements ypNumber = doc.select("el-input[placeholder~=样品编号.*]");
+            Elements ypCount = doc.select("el-input[placeholder~=样品数量.*]");
+            Elements ypMs = doc.select("el-input[placeholder~=样品描述.*]");
+
+            //获取样品信息
+            if (StringUtils.isNotEmpty(sampleIds)) {
+                List<TrialSampleInfo> trialSampleInfoList = jdbcTemplate.query("select material_name,specification_number,sample_description,material_count from u_trial_sample_info where id in(" + sampleIds + ")", new BeanPropertyRowMapper<>(TrialSampleInfo.class));
+                List<String> names = trialSampleInfoList.stream().map(TrialSampleInfo::getMaterialName).collect(Collectors.toList());
+                List<String> numbers = trialSampleInfoList.stream().map(TrialSampleInfo::getSpecificationNumber).collect(Collectors.toList());
+                List<String> descriptions = trialSampleInfoList.stream().map(TrialSampleInfo::getSampleDescription).collect(Collectors.toList());
+                List<Integer> counts = trialSampleInfoList.stream().map(TrialSampleInfo::getMaterialCount).collect(Collectors.toList());
+
+                //样品名称
+                if (ypName.size() >= 1) {
+                    for (Element element : ypName) {
+                        int trIndex = Integer.parseInt(element.attr("trindex"));
+                        if (trIndex <= 6) {
+                            resultMap.put(element.attr("keyName"), ObjectUtils.isNotEmpty(names) ? StringUtils.join(names, "、") : "");
+                        }
+                    }
+                }
+                //样品编号
+                if (ypNumber.size() >= 1) {
+                    for (Element element : ypNumber) {
+                        int trIndex = Integer.parseInt(element.attr("trindex"));
+                        if (trIndex <= 6) {
+                            resultMap.put(element.attr("keyName"), ObjectUtils.isNotEmpty(numbers) ? StringUtils.join(numbers, "、") : "");
+                        }
+                    }
+                }
+                //样品数量
+                if (ypCount.size() >= 1) {
+                    for (Element element : ypCount) {
+                        int trIndex = Integer.parseInt(element.attr("trindex"));
+                        if (trIndex <= 6) {
+                            resultMap.put(element.attr("keyName"), ObjectUtils.isNotEmpty(counts) ? counts.stream().reduce(Integer::sum).orElse(0).toString() : "");
+                        }
+                    }
+                }
+                //样品描述
+                if (ypMs.size() >= 1) {
+                    for (Element element : ypMs) {
+                        int trIndex = Integer.parseInt(element.attr("trindex"));
+                        if (trIndex <= 6) {
+                            resultMap.put(element.attr("keyName"), ObjectUtils.isNotEmpty(descriptions) ? StringUtils.join(descriptions, "、") : "");
+                        }
+                    }
+                }
+
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return resultMap;
+    }
+
 }
 
 

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

@@ -662,6 +662,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
     }
 
     @Override
+    @Async
     public void updateTrialSelfInspectionRecordStatusFC(TaskApprovalVO obj) {
         if (ObjectUtil.isNotEmpty(obj.getParallelProcessInstanceId())) {
             String sql = "select process_instance_id from u_task_parallel where parallel_process_instance_id = '" + obj.getParallelProcessInstanceId() + "'";

+ 12 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreePrivateController.java

@@ -382,6 +382,18 @@ public class WbsTreePrivateController extends BladeController {
     }
 
 
+    @PostMapping("/self/trial/getMixRatioTestTree")
+    @ApiOperationSupport(order = 5)
+    @ApiOperation(value = "获取当前节点的试验配合比树", notes = "传入当前节点的pKeyId")
+    public R<List<WbsTreePrivateVO>> getMixRatioTestTree(String pKeyId) {
+        List<WbsTreePrivateVO> tree = wbsTreePrivateService.getMixRatioTestTree(pKeyId);
+        if (tree != null && tree.size() > 0) {
+            return R.data(tree);
+        }
+        return R.fail(200, "未查询到信息");
+    }
+
+
     /**
      * 获取当前节点详情
      */

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

@@ -216,7 +216,7 @@
         SET sort = #{sort}
         WHERE p_key_id = #{pKeyId}
           AND type = 2
-          AND status = 1
+          -- AND status = 1
           AND is_deleted = 0
     </update>
 

+ 2 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IWbsTreePrivateService.java

@@ -82,4 +82,6 @@ public interface IWbsTreePrivateService extends BaseService<WbsTreePrivate> {
     //批量重新保存文件htmlUrl
     void batchResetHtmlUrl(List<WbsTreePrivate> wbsTreePrivateList) throws IOException, InterruptedException;
 
+    List<WbsTreePrivateVO> getMixRatioTestTree(String pKeyId);
+
 }

+ 53 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreePrivateServiceImpl.java

@@ -1333,7 +1333,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
 
                 //获取当前项目节点树
                 Map<Long, WbsTreePrivate> nowNodeTreeAll = wbsTreePrivatesNodeAndTabNow.stream().filter(f -> f.getType().equals(1)).collect(Collectors.toList()).stream()
-                        .collect(Collectors.toMap(WbsTreePrivate::getId, Function.identity()));
+                        .collect(Collectors.toMap(WbsTreePrivate::getId, WbsTreePrivate -> WbsTreePrivate, (obj1, obj2) -> obj1));
 
                 //获取当前引用的节点树下所有节点、表、独立表
                 String sqlNodeTreeAllOld = "SELECT p_key_id,id,type,parent_id FROM m_wbs_tree_private WHERE project_id = " + oneRecordRoot.getProjectId() + " AND STATUS = 1 AND is_deleted = 0 AND (((type = 1 OR type = 2) AND wbs_id = " + oneRecordRoot.getWbsId() + ") OR ((type= 10 OR parent_id = -10 ) AND wbs_id IS NULL))";
@@ -1484,17 +1484,67 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
                 tree.setHtmlUrl(htmlUrl);
             }
             //批量修改
-            if (wbsTreePrivateList.size() > 1000){
+            if (wbsTreePrivateList.size() > 1000) {
                 List<List<WbsTreePrivate>> splitList = CommonUtil.splitList(wbsTreePrivateList, 1000);
                 for (List<WbsTreePrivate> list : splitList) {
                     baseMapper.updateBatchByPKeyId(list);
                 }
-            }else {
+            } else {
                 baseMapper.updateBatchByPKeyId(wbsTreePrivateList);
             }
         }
     }
 
+    @Override
+    public List<WbsTreePrivateVO> getMixRatioTestTree(String pKeyId) {
+        WbsTreePrivate wbsTreePrivate = baseMapper.selectOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, pKeyId));
+        if (wbsTreePrivate != null && StringUtils.isNotEmpty(wbsTreePrivate.getMixRatioTestIds())) {
+            String ids = wbsTreePrivate.getMixRatioTestIds();
+            List<WbsTreePrivate> wbsTreePrivates = baseMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery()
+                    .in(WbsTreePrivate::getId, Func.toLongList(ids))
+                    .eq(WbsTreePrivate::getProjectId, wbsTreePrivate.getProjectId())
+                    .eq(WbsTreePrivate::getWbsId, wbsTreePrivate.getWbsId())
+                    .eq(WbsTreePrivate::getWbsType, wbsTreePrivate.getWbsType())
+                    .eq(WbsTreePrivate::getStatus, 1));
+
+            WbsTreePrivate root = wbsTreePrivates.stream().filter(f -> f.getParentId() == 0L).findAny().orElse(null);
+            if (root == null) {
+                WbsTreePrivate rootNode = baseMapper.selectOne(Wrappers.<WbsTreePrivate>lambdaQuery()
+                        .eq(WbsTreePrivate::getParentId, 0L)
+                        .eq(WbsTreePrivate::getProjectId, wbsTreePrivate.getProjectId())
+                        .eq(WbsTreePrivate::getWbsId, wbsTreePrivate.getWbsId())
+                        .eq(WbsTreePrivate::getWbsType, wbsTreePrivate.getWbsType())
+                        .eq(WbsTreePrivate::getStatus, 1));
+                if (rootNode != null) {
+                    wbsTreePrivates.add(rootNode);
+                }
+            }
+
+            List<WbsTreePrivateVO> wbsTreePrivateVOS = BeanUtil.copyProperties(wbsTreePrivates, WbsTreePrivateVO.class);
+            return this.buildWbsTreeByStream(wbsTreePrivateVOS);
+        } else {
+            throw new ServiceException("当前节点下未配置勾选相关联试验的配合比节点");
+        }
+    }
+
+    private List<WbsTreePrivateVO> buildWbsTreeByStream(List<WbsTreePrivateVO> wbsTreePrivateVOS) {
+        List<WbsTreePrivateVO> list = wbsTreePrivateVOS.stream().filter(f -> f.getParentId() == 0L).collect(Collectors.toList());
+        Map<Long, List<WbsTreePrivateVO>> map = wbsTreePrivateVOS.stream().collect(Collectors.groupingBy(WbsTreePrivateVO::getParentId));
+        this.recursionFnTree(list, map);
+        return list;
+    }
+
+    private void recursionFnTree(List<WbsTreePrivateVO> list, Map<Long, List<WbsTreePrivateVO>> map) {
+        for (WbsTreePrivateVO wbsTreePrivateVO : list) {
+            List<WbsTreePrivateVO> childrenList = map.get(wbsTreePrivateVO.getId());
+            wbsTreePrivateVO.setChildren(childrenList);
+            if (childrenList != null && childrenList.size() > 0) {
+                wbsTreePrivateVO.setHasChildren(true);
+                recursionFnTree(childrenList, map);
+            }
+        }
+    }
+
     @Override
     public R addWbsTreeContractInfo(String nodeId, String primaryKeyIds, long contractId) {
         if (com.alibaba.cloud.commons.lang.StringUtils.isEmpty(nodeId)) {