Pārlūkot izejas kodu

试验编号优化

cr 2 mēneši atpakaļ
vecāks
revīzija
bb9293d74e

+ 24 - 21
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialMaterialMobilizationServiceImpl.java

@@ -152,33 +152,36 @@ public class TrialMaterialMobilizationServiceImpl extends BaseServiceImpl<TrialM
 
         IPage<TrialMaterialMobilizationVO> trialMaterialMobilizationVOIPage = TrialMaterialMobilizationWarpper.build().pageVO(pages);
         List<TrialMaterialMobilizationVO> records = trialMaterialMobilizationVOIPage.getRecords();
-        Map<String, String> fileMaps = jdbcTemplate.query("select link,original_name from blade_attach", new BeanPropertyRowMapper<>(Attach.class)).stream().collect(Collectors.toMap(Attach::getLink, Attach::getOriginalName, (key1, key2) -> key2));
-        for (TrialMaterialMobilizationVO record : records) {
-            for (User user : userList) {
-                if (user.getId().equals(record.getUserId())) {
-                    record.setUserName(user.getName());
-                    break;
+        if(!records.isEmpty()){
+            Map<String, String> fileMaps = jdbcTemplate.query("select link,original_name from blade_attach", new BeanPropertyRowMapper<>(Attach.class)).stream().collect(Collectors.toMap(Attach::getLink, Attach::getOriginalName, (key1, key2) -> key2));
+            for (TrialMaterialMobilizationVO record : records) {
+                for (User user : userList) {
+                    if (user.getId().equals(record.getUserId())) {
+                        record.setUserName(user.getName());
+                        break;
+                    }
                 }
-            }
-            if (StringUtils.isNotEmpty(record.getOtherAccessories())) {
-                String attach = fileMaps.get(record.getOtherAccessories());
-                if (attach != null) {
-                    record.setOtherAccessoriesName(attach);
+                if (StringUtils.isNotEmpty(record.getOtherAccessories())) {
+                    String attach = fileMaps.get(record.getOtherAccessories());
+                    if (attach != null) {
+                        record.setOtherAccessoriesName(attach);
+                    }
                 }
-            }
-            if (StringUtils.isNotEmpty(record.getProductionCertificate())) {
-                String attach = fileMaps.get(record.getProductionCertificate());
-                if (attach != null) {
-                    record.setProductionCertificateName(attach);
+                if (StringUtils.isNotEmpty(record.getProductionCertificate())) {
+                    String attach = fileMaps.get(record.getProductionCertificate());
+                    if (attach != null) {
+                        record.setProductionCertificateName(attach);
+                    }
                 }
-            }
-            if (StringUtils.isNotEmpty(record.getQualityInspectionReport())) {
-                String attach = fileMaps.get(record.getQualityInspectionReport());
-                if (attach != null) {
-                    record.setQualityInspectionReportName(attach);
+                if (StringUtils.isNotEmpty(record.getQualityInspectionReport())) {
+                    String attach = fileMaps.get(record.getQualityInspectionReport());
+                    if (attach != null) {
+                        record.setQualityInspectionReportName(attach);
+                    }
                 }
             }
         }
+
         return trialMaterialMobilizationVOIPage.setRecords(records);
     }
 

+ 28 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialNumberRuleServiceImpl.java

@@ -256,6 +256,34 @@ public class TrialNumberRuleServiceImpl extends BaseServiceImpl<TrialNumberRuleM
         }else {
             trialNumberRules = baseMapper.selectList(Wrappers.<TrialNumberRule>query().lambda().eq(TrialNumberRule::getContractId, contractId).eq(TrialNumberRule::getType, type).eq(TrialNumberRule::getStatus,2).orderByAsc(TrialNumberRule::getSort));
         }
+        if(trialNumberRules.size()>0){
+            for (TrialNumberRule rule : trialNumberRules) {
+                if(rule.getRule()==2){
+                    if(rule.getContractId()==null||rule.getContractId()==0L){
+                        rule.setData("TJ01");
+                    }else {
+                        String sql1="select contract_number from m_contract_info where id="+contractId;
+                        String result = jdbcTemplate.query(sql1, rs -> {
+                            if (rs.next()) {
+                                return rs.getString(1);
+                            } else {
+                                return "";
+                            }
+                        });
+                        rule.setData(result);
+                    }
+                } else if (rule.getRule()==3) {
+                    rule.setData("SNY");
+                } else if (rule.getRule()==4) {
+                    String currentYearStr = String.valueOf(LocalDate.now().getYear());
+                    rule.setData(currentYearStr);
+                } else if (rule.getRule()==5) {
+                    int currentMonthValue = LocalDate.now().getMonthValue();
+                    String currentMonthStr = String.format("%02d", currentMonthValue);
+                    rule.setData(currentMonthStr);
+                }
+            }
+        }
         if(trialNumberRules!=null){
             Map<String, String> map = getTrialNumber(projectId,contractId, type, null, false);
             vo1.setList(trialNumberRules);