Browse Source

08 04 01 relation codes

hr 4 years ago
parent
commit
12470d6f01

+ 2 - 1
src/main/java/com/imed/costaccount/model/dto/ReportRelationDTO.java

@@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.hibernate.validator.constraints.Range;
 
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
 import javax.validation.constraints.NotNull;
 import java.util.List;
 
@@ -18,7 +20,6 @@ public class ReportRelationDTO {
 
     @ApiModelProperty(name = "relation",value = "1.对应会计科目设置,2.对应分摊参数设置")
     @NotNull(message = "报表项目关联关系不能为空")
-    @Range(min = 1,max = 2)
     private Integer relation;
 
     private List<String> relationCodes;

+ 4 - 2
src/main/java/com/imed/costaccount/service/impl/ReportRelationServiceImpl.java

@@ -152,7 +152,7 @@ public class ReportRelationServiceImpl extends ServiceImpl<ReportRelationMapper,
                 new LambdaQueryWrapper<ReportRelation>().eq(ReportRelation::getReportId, reportId).eq(ReportRelation::getHospId, hospId)
         );
         if (!list.isEmpty()) {
-            baseMapper.deleteBatchIds(list);
+            baseMapper.deleteBatchIds(list.stream().map(ReportRelation::getId).collect(Collectors.toList()));
         }
         List<ReportRelation> reportRelations = relationCodes.stream().map(code -> {
             ReportRelation reportRelation = new ReportRelation();
@@ -183,7 +183,9 @@ public class ReportRelationServiceImpl extends ServiceImpl<ReportRelationMapper,
                         .eq(ReportRelation::getHospId, hospId)
         );
         if (CollUtil.isNotEmpty(relations)) {
-            throw new CostException(500, "编码为:" + StrUtil.join(StrUtil.COMMA, relation) + "已被绑定");
+            throw new CostException(500, "编码为:" +
+                    StrUtil.join(StrUtil.COMMA, relations.stream().map(ReportRelation::getRelationCode).collect(Collectors.toList())) +
+                    "已被其他项目代码绑定");
         }
     }
 }