Преглед на файлове

菜单权限bug、试验bug相关

liuyc преди 2 години
родител
ревизия
8bb8a21747

+ 0 - 36
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/SampleAncillaryDocumentsVO.java

@@ -1,36 +0,0 @@
-package org.springblade.business.vo;
-
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import java.io.Serializable;
-
-
-@Data
-public class SampleAncillaryDocumentsVO implements Serializable {
-
-    @ApiModelProperty("材料id")
-    private Long id;
-
-    @ApiModelProperty("材料名称")
-    private String name;
-
-    @ApiModelProperty(value = "生产合格证")
-    private String productionCertificate;
-
-    @ApiModelProperty(value = "生产合格证名称")
-    private String productionCertificateName;
-
-    @ApiModelProperty(value = "厂家质检报告")
-    private String qualityInspectionReport;
-
-    @ApiModelProperty(value = "厂家质检报告名称")
-    private String qualityInspectionReportName;
-
-    @ApiModelProperty(value = "其他附件")
-    private String otherAccessories;
-
-    @ApiModelProperty(value = "其他附件名称")
-    private String otherAccessoriesName;
-
-}

+ 18 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/TrialRecordAncillaryDocumentsVO.java

@@ -0,0 +1,18 @@
+package org.springblade.business.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class TrialRecordAncillaryDocumentsVO implements Serializable {
+
+    private Long id;
+
+    private String fileName;
+
+    private String url;
+
+    private Integer isDel;
+
+}

+ 18 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/TrialSelfInspectionRecordFileVO.java

@@ -0,0 +1,18 @@
+package org.springblade.business.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class TrialSelfInspectionRecordFileVO implements Serializable {
+
+    private Long id;
+
+    private Long selfId;
+
+    private String url;
+
+    private Integer type;
+
+}

+ 1 - 3
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/feign/WbsTreePrivateClient.java

@@ -1,5 +1,6 @@
 package org.springblade.manager.feign;
 
+import org.springblade.core.tool.api.R;
 import org.springblade.manager.entity.WbsTreePrivate;
 import org.springblade.manager.vo.WbsTreeContractTreeVOS;
 import org.springblade.manager.vo.WbsTreePrivateVO;
@@ -42,9 +43,6 @@ public interface WbsTreePrivateClient {
     @PostMapping(API_PREFIX + "/copyBussTab")
     boolean copyBussTab(@RequestParam Long pKeyId, @RequestParam Long id, @RequestParam Long contractId);
 
-    @PostMapping(API_PREFIX + "/removeBussTabInfoById")
-    boolean removeBussTabInfoById(@RequestParam Long pKeyId);
-
     @PostMapping(API_PREFIX + "/getRawMaterialTree")
     List<WbsTreePrivateVO> getRawMaterialTree(@RequestParam Long pKeyId);
 

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

@@ -119,17 +119,24 @@ public class TrialDetectionController extends BladeController {
     @GetMapping("/self/ancillary-documents-list")
     @ApiOperationSupport(order = 9)
     @ApiOperation(value = "自检记录附件列表", notes = "传入记录id")
-    public R<List<SampleAncillaryDocumentsVO>> selfAncillaryDocumentsList(@Valid @RequestParam String id) {
-        return R.data(iTrialSelfInspectionRecordService.selfAncillaryDocumentsList(id));
+    public R<List<TrialRecordAncillaryDocumentsVO>> selfAncillaryDocumentsList(@RequestParam String id, @RequestParam String type) {
+        return R.data(iTrialSelfInspectionRecordService.selfAncillaryDocumentsList(id, type));
     }
 
     @PostMapping("/self/update-ancillary-documents")
     @ApiOperationSupport(order = 10)
-    @ApiOperation(value = "自检记录修改附件", notes = "传入SampleAncillaryDocumentsVO")
-    public R<Object> selfUpdateAncillaryDocuments(@Valid @RequestBody SampleAncillaryDocumentsVO vo) {
+    @ApiOperation(value = "自检记录附件上传", notes = "传入TrialSelfInspectionRecordFileVO")
+    public R<Object> selfUpdateAncillaryDocuments(@Valid @RequestBody TrialSelfInspectionRecordFileVO vo) {
         return R.status(iTrialSelfInspectionRecordService.selfUpdateAncillaryDocuments(vo));
     }
 
+    @PostMapping("/self/remove-ancillary-documents")
+    @ApiOperationSupport(order = 10)
+    @ApiOperation(value = "自检记录附件删除", notes = "传入附件id")
+    public R<Object> selfRemoveAncillaryDocuments(@RequestParam String id) {
+        return R.status(iTrialSelfInspectionRecordService.selfRemoveAncillaryDocuments(id));
+    }
+
     @PostMapping("/self/submit")
     @ApiOperationSupport(order = 11)
     @ApiOperation(value = "自检记录新增或修改", notes = "传入TrialSelfInspectionRecordDTO")
@@ -238,8 +245,15 @@ public class TrialDetectionController extends BladeController {
     @PostMapping("/self/remove-buss-tab")
     @ApiOperationSupport(order = 16)
     @ApiOperation(value = "自检删除复制的表", notes = "传入节点pKeyId")
-    public R<Object> removeBussTabInfo(@RequestParam Long pKeyId) {
-        return R.status(wbsTreePrivateClient.removeBussTabInfoById(pKeyId));
+    public R<String> removeBussTabInfo(@RequestParam Long pKeyId) {
+        //查询当前表是否已经填报
+        List<TrialSelfDataRecord> query = jdbcTemplate.query("select id from u_trial_self_data_record where tab_id = " + pKeyId, new BeanPropertyRowMapper<>(TrialSelfDataRecord.class));
+        if (query.size() > 0) {
+            return R.fail("当前表在试验记录中有填报数据,删除失败");
+        } else {
+            jdbcTemplate.execute("delete from m_wbs_tree_private where p_key_id = " + pKeyId);
+            return R.success("删除成功");
+        }
     }
 
     @GetMapping("/get-buss-pdf")

+ 4 - 3
blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialSelfInspectionRecordService.java

@@ -19,9 +19,11 @@ public interface ITrialSelfInspectionRecordService extends BaseService<TrialSelf
 
     List<TrialSampleInfoVO> selfSampleList(String id);
 
-    List<SampleAncillaryDocumentsVO> selfAncillaryDocumentsList(String id);
+    List<TrialRecordAncillaryDocumentsVO> selfAncillaryDocumentsList(String id, String type);
 
-    boolean selfUpdateAncillaryDocuments(SampleAncillaryDocumentsVO vo);
+    boolean selfUpdateAncillaryDocuments(TrialSelfInspectionRecordFileVO vo);
+
+    boolean selfRemoveAncillaryDocuments(String id);
 
     boolean selfCopy(List<Long> toLongList);
 
@@ -41,5 +43,4 @@ public interface ITrialSelfInspectionRecordService extends BaseService<TrialSelf
 
     boolean fileSubmit(TrialFileSubmitDTO dto) throws FileNotFoundException;
 
-
 }

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

@@ -44,6 +44,7 @@ import org.springblade.system.entity.Dict;
 import org.springblade.system.feign.IDictClient;
 import org.springblade.system.user.entity.User;
 import org.springblade.system.user.feign.IUserClient;
+import org.springframework.context.annotation.Bean;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.scheduling.annotation.Async;
@@ -229,9 +230,37 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
     }
 
     @Override
-    public List<SampleAncillaryDocumentsVO> selfAncillaryDocumentsList(String id) {
-        //获取材料附件信息
-        List<SampleAncillaryDocumentsVO> result = new ArrayList<>();
+    public List<TrialRecordAncillaryDocumentsVO> selfAncillaryDocumentsList(String id, String type) {
+        //关联取样附件
+        List<TrialRecordAncillaryDocumentsVO> resultData = new ArrayList<>();
+        this.getRecordAncillaryDocumentList(resultData, id, type);
+
+        //其他上传附件
+        List<TrialSelfInspectionRecordFileVO> queryFileVos = jdbcTemplate.query("select id,self_id,url,type from u_trial_self_inspection_record_file where self_id = " + id + " and type = " + type, new BeanPropertyRowMapper<>(TrialSelfInspectionRecordFileVO.class));
+        for (TrialSelfInspectionRecordFileVO fileVO : queryFileVos) {
+            TrialRecordAncillaryDocumentsVO obj = new TrialRecordAncillaryDocumentsVO();
+            obj.setIsDel(1); //其他可以删除
+            obj.setId(fileVO.getId());
+            obj.setUrl(fileVO.getUrl());
+            resultData.add(obj);
+        }
+
+        Map<String, Attach> maps = jdbcTemplate.query("select link,original_name from blade_attach", new BeanPropertyRowMapper<>(Attach.class)).stream().collect(Collectors.toMap(Attach::getLink, Attach -> Attach, (obj1, obj2) -> obj1));
+        for (TrialRecordAncillaryDocumentsVO vo : resultData) {
+            Attach att = maps.get(vo.getUrl());
+            if (att != null) {
+                //文件名
+                vo.setFileName(ObjectUtil.isNotEmpty(att.getOriginalName()) ? att.getOriginalName() : "没有找到对应的上传文件名称");
+            }
+            if (ObjectUtil.isEmpty(vo.getFileName())) {
+                String name = vo.getUrl().split("//upload/")[1].split("/")[1];
+                vo.setFileName(name);
+            }
+        }
+        return resultData;
+    }
+
+    private void getRecordAncillaryDocumentList(List<TrialRecordAncillaryDocumentsVO> result, String id, String type) {
         //获取样品ids
         List<String> sampleIds = baseMapper.selectSelfSampleRecord(id);
         if (sampleIds.size() > 0) {
@@ -246,62 +275,31 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
             if (mobilizationIds.size() > 0) {
                 List<TrialMaterialMobilization> trialMaterialMobilizations = trialMaterialMobilizationMapper.selectBatchIds(mobilizationIds);
                 for (TrialMaterialMobilization trialMaterialMobilization : trialMaterialMobilizations) {
-                    SampleAncillaryDocumentsVO obj = new SampleAncillaryDocumentsVO();
+                    TrialRecordAncillaryDocumentsVO obj = new TrialRecordAncillaryDocumentsVO();
                     obj.setId(trialMaterialMobilization.getId());
-                    obj.setName(trialMaterialMobilization.getMaterialName());
-                    obj.setOtherAccessories(trialMaterialMobilization.getOtherAccessories());
-                    obj.setProductionCertificate(trialMaterialMobilization.getProductionCertificate());
-                    obj.setQualityInspectionReport(trialMaterialMobilization.getQualityInspectionReport());
+                    if ("1".equals(type)) {
+                        obj.setUrl(trialMaterialMobilization.getProductionCertificate());
+                    } else if ("2".equals(type)) {
+                        obj.setUrl(trialMaterialMobilization.getQualityInspectionReport());
+                    } else if ("3".equals(type)) {
+                        obj.setUrl(trialMaterialMobilization.getOtherAccessories());
+                    }
+                    obj.setIsDel(0); //关联的取样文件不能删除
                     result.add(obj);
                 }
             }
         }
-
-        String sql = "select link,original_name from blade_attach";
-        List<Attach> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(Attach.class));
-        for (SampleAncillaryDocumentsVO sampleAncillaryDocumentsVO : result) {
-            for (Attach attach : query) {
-                if (StringUtils.isNotEmpty(sampleAncillaryDocumentsVO.getOtherAccessories()) && sampleAncillaryDocumentsVO.getOtherAccessories().equals(attach.getLink())) {
-                    sampleAncillaryDocumentsVO.setOtherAccessoriesName(attach.getOriginalName());
-                } else if (StringUtils.isNotEmpty(sampleAncillaryDocumentsVO.getOtherAccessories()) && !sampleAncillaryDocumentsVO.getOtherAccessories().equals(attach.getLink())) {
-                    sampleAncillaryDocumentsVO.setOtherAccessoriesName(sampleAncillaryDocumentsVO.getOtherAccessories());
-                }
-
-                if (StringUtils.isNotEmpty(sampleAncillaryDocumentsVO.getProductionCertificate()) && sampleAncillaryDocumentsVO.getProductionCertificate().equals(attach.getLink())) {
-                    sampleAncillaryDocumentsVO.setProductionCertificateName(attach.getOriginalName());
-                } else if (StringUtils.isNotEmpty(sampleAncillaryDocumentsVO.getProductionCertificate()) && !sampleAncillaryDocumentsVO.getProductionCertificate().equals(attach.getLink())) {
-                    sampleAncillaryDocumentsVO.setProductionCertificateName(sampleAncillaryDocumentsVO.getProductionCertificate());
-                }
-
-                if (StringUtils.isNotEmpty(sampleAncillaryDocumentsVO.getQualityInspectionReport()) && sampleAncillaryDocumentsVO.getQualityInspectionReport().equals(attach.getLink())) {
-                    sampleAncillaryDocumentsVO.setQualityInspectionReportName(attach.getOriginalName());
-                } else if (StringUtils.isNotEmpty(sampleAncillaryDocumentsVO.getQualityInspectionReport()) && !sampleAncillaryDocumentsVO.getQualityInspectionReport().equals(attach.getLink())) {
-                    sampleAncillaryDocumentsVO.setQualityInspectionReportName(sampleAncillaryDocumentsVO.getQualityInspectionReport());
-                }
-            }
-        }
-
-        return result;
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
-    public boolean selfUpdateAncillaryDocuments(SampleAncillaryDocumentsVO vo) {
-        TrialMaterialMobilization trialMaterialMobilization = trialMaterialMobilizationMapper.selectById(vo.getId());
-        if (ObjectUtil.isEmpty(trialMaterialMobilization)) {
-            throw new ServiceException("未获取到对应材料信息,修改失败");
-        }
-        if (StringUtils.isNotEmpty(vo.getQualityInspectionReport())) {
-            trialMaterialMobilization.setQualityInspectionReport(vo.getQualityInspectionReport());
-        }
-        if (StringUtils.isNotEmpty(vo.getOtherAccessories())) {
-            trialMaterialMobilization.setOtherAccessories(vo.getOtherAccessories());
-        }
-        if (StringUtils.isNotEmpty(vo.getProductionCertificate())) {
-            trialMaterialMobilization.setProductionCertificate(vo.getProductionCertificate());
-        }
-        trialMaterialMobilizationMapper.updateById(trialMaterialMobilization);
+    public boolean selfUpdateAncillaryDocuments(TrialSelfInspectionRecordFileVO vo) {
+        jdbcTemplate.execute("insert into u_trial_self_inspection_record_file (id,self_id,url,type) values (" + SnowFlakeUtil.getId() + "," + vo.getSelfId() + ",'" + vo.getUrl() + "'," + vo.getType() + ")");
+        return true;
+    }
 
+    @Override
+    public boolean selfRemoveAncillaryDocuments(String id) {
+        jdbcTemplate.execute("delete from u_trial_self_inspection_record_file where id = " + id);
         return true;
     }
 

+ 1 - 12
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/WbsTreePrivateClientImpl.java

@@ -10,6 +10,7 @@ import lombok.AllArgsConstructor;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.node.ForestNodeMerger;
 import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.Func;
@@ -152,18 +153,6 @@ public class WbsTreePrivateClientImpl implements WbsTreePrivateClient {
         return false;
     }
 
-    @Override
-    public boolean removeBussTabInfoById(Long pKeyId) {
-        //查询当前表是否已经填报
-        List<TrialSelfDataRecord> query = jdbcTemplate.query("select id from u_trial_self_data_record where tab_id = " + pKeyId, new BeanPropertyRowMapper<>(TrialSelfDataRecord.class));
-        if (query.size() > 0) {
-            throw new ServiceException("当前表在试验记录中有填报数据,删除失败");
-        } else {
-            jdbcTemplate.execute("delete from m_wbs_tree_private where p_key_id = " + pKeyId);
-            return true;
-        }
-    }
-
     @Override
     public List<WbsTreePrivateVO> getRawMaterialTree(Long pKeyId) {
         WbsTreePrivate wbsTreePrivate = wbsTreePrivateService.getBaseMapper().selectOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, pKeyId));

+ 4 - 3
blade-service/blade-system/src/main/java/org/springblade/system/service/impl/MenuServiceImpl.java

@@ -96,6 +96,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IM
 
         //根据类型获取对应菜单
         List<Menu> allMenusList = baseMapper.allMenuBySysType(sysType);
+        Long sysId = allMenusList.stream().map(Menu::getSysId).findAny().orElse(null);
         List<Menu> newAllMenusList = BeanUtil.copyProperties(allMenusList, Menu.class);
 
         //只显示非隐藏按钮
@@ -143,15 +144,15 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IM
                     routes.stream().anyMatch(route -> route.getId().longValue() == x.getId().longValue())
             ).collect(Collectors.toList());
         }
-        return buildRoutes(allMenus, roleMenus);
+        return buildRoutes(allMenus, roleMenus, sysId);
     }
 
-    private List<MenuVO> buildRoutes(List<Menu> allMenus, List<Menu> roleMenus) {
+    private List<MenuVO> buildRoutes(List<Menu> allMenus, List<Menu> roleMenus, Long sysId) {
         List<Menu> routes = new LinkedList<>(roleMenus);
         roleMenus.forEach(roleMenu -> recursion(allMenus, routes, roleMenu));
         routes.sort(Comparator.comparing(Menu::getSort));
         MenuWrapper menuWrapper = new MenuWrapper();
-        List<Menu> collect = routes.stream().filter(x -> Func.equals(x.getCategory(), 1)).collect(Collectors.toList());
+        List<Menu> collect = routes.stream().filter(x -> Func.equals(x.getCategory(), 1) && sysId.equals(x.getSysId())).collect(Collectors.toList());
         return menuWrapper.listNodeVO(collect);
     }