考试规则数量,标签 针对实训线路过滤调整

This commit is contained in:
tiger_zhou 2023-01-31 10:57:44 +08:00
parent fc5b8721b7
commit 68bbde3029
2 changed files with 18 additions and 17 deletions

View File

@ -16,11 +16,11 @@ import java.util.Map;
@Repository @Repository
public interface PublishedTraining2DAO { public interface PublishedTraining2DAO {
@Select("<script>select label_json from rts_published_training2 where 1 = 1 " + /* @Select("<script>select label_json from rts_published_training2 where 1 = 1 " +
"<if test=\"orgId != null\"> " + "<if test=\"orgId != null\"> " +
" and org_id = #{orgId} " + " and org_id = #{orgId} " +
" </if> and type = #{type} and map_id = #{mapId}</script>") " </if> and type = #{type} and map_id = #{mapId}</script>")
List<String> selectAllLabel(@Param("mapId") Long mapId,@Param("orgId") Long orgId,@Param("type") String type); List<String> selectAllLabel(@Param("mapId") Long mapId,@Param("orgId") Long orgId,@Param("type") String type);*/
long countByExample(PublishedTraining2Example example); long countByExample(PublishedTraining2Example example);
int deleteByExample(PublishedTraining2Example example); int deleteByExample(PublishedTraining2Example example);

View File

@ -49,16 +49,9 @@ public class Training2PublishService {
*/ */
public Long queryCountForLabel(Long mapId,@Deprecated Long orgId,String type,String label){ public Long queryCountForLabel(Long mapId,@Deprecated Long orgId,String type,String label){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(mapId),"没有关联对应的地图");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(orgId),"组织信息不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(type),"查询类型信息不能为空");
PublishedTraining2Example example = new PublishedTraining2Example(); PublishedTraining2Example example = new PublishedTraining2Example();
PublishedTraining2Example.Criteria c = example.createCriteria(); PublishedTraining2Example.Criteria c = example.createCriteria();
//针对实训只过滤对应的线路 this.findAllLableCriteria(c,mapId,orgId,type);
c.andMapIdEqualTo(mapId);
// c.andOrgIdEqualTo(orgId);
c.andTypeEqualTo(type);
if(Objects.nonNull(label)){ if(Objects.nonNull(label)){
c.andLabelJsonLike(String.format("%%%s%%", label)); c.andLabelJsonLike(String.format("%%%s%%", label));
} }
@ -69,20 +62,28 @@ public class Training2PublishService {
* 根据 组织类型单操作实操 获取标签 * 根据 组织类型单操作实操 获取标签
*/ */
public Collection<String> findAllLabel(Long mapId,Long orgId, String type){ public Collection<String> findAllLabel(Long mapId,Long orgId, String type){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(mapId),"请关联对应的线路"); PublishedTraining2Example example = new PublishedTraining2Example();
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(orgId),"组织信息不能为空"); PublishedTraining2Example.Criteria c = example.createCriteria();
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(type),"查询类型信息不能为空"); this.findAllLableCriteria(c,mapId,orgId,type);
//针对实训只过滤关联的线路 List<PublishedTraining2> dataList = this.publishedDao.selectByExample(example);
List<String> list = this.publishedDao.selectAllLabel(mapId,null,type); if(CollectionUtils.isEmpty(dataList)){
if(CollectionUtils.isEmpty(list)){
return Collections.emptyList(); return Collections.emptyList();
} }
return list.stream().filter(StringUtils::hasText).map(d->{ return dataList.stream().map(PublishedTraining2::getLabelJson).filter(StringUtils::hasText).map(d->{
List<String> l = JsonUtils.readCollection(d,List.class,String.class); List<String> l = JsonUtils.readCollection(d,List.class,String.class);
return l; return l;
}).flatMap(d->d.stream()).collect(Collectors.toSet()); }).flatMap(d->d.stream()).collect(Collectors.toSet());
} }
private void findAllLableCriteria(PublishedTraining2Example.Criteria criteria,Long mapId,Long orgId,String type){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(mapId),"请关联对应的线路");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(orgId),"组织信息不能为空");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(type),"查询类型信息不能为空");
criteria.andMapIdEqualTo(mapId);
// c.andOrgIdEqualTo(orgId);
criteria.andTypeEqualTo(type);
}
/** /**
* 已发布实训分页列表 * 已发布实训分页列表
*/ */