| | |
| | | import com.lf.server.service.data.MetaService; |
| | | import com.lf.server.service.data.VerService; |
| | | import com.lf.server.service.show.DataLibService; |
| | | import com.lf.server.service.sys.DownlogService; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | |
| | | @ApiOperation(value = "分页查询元数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "depcode", value = "单位编码", dataType = "String", paramType = "query", example = "00"), |
| | | @ApiImplicitParam(name = "dirs", value = "目录编码", dataType = "String", paramType = "query", example = "00,01"), |
| | | @ApiImplicitParam(name = "types", value = "资料类别", dataType = "String", paramType = "query", example = "基础测绘,基础地灾,基础勘察,合规数据,管理数据,测绘(ESV),勘察(EGE),地灾(EGD),洞库(EGD)"), |
| | | @ApiImplicitParam(name = "dirs", value = "项目编码", dataType = "String", paramType = "query", example = ""), |
| | | @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = ""), |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectMetasForPage") |
| | | public ResponseMsg<Object> selectMetasForPage(String depcode, String dirs, String name, Integer pageSize, Integer pageIndex) { |
| | | public ResponseMsg<Object> selectMetasForPage(String depcode, String types, String dirs, String name, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | dirs = DataLibService.copeCodes(dirs, "dircode"); |
| | | |
| | | |
| | | int count = metaService.selectMetasForCount(depcode, dirs, name); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | |
| | | public List<KeyValueEntity> selectDirTypes(String name); |
| | | |
| | | /** |
| | | * 根据资料类别查询目录 |
| | | * |
| | | * @param types |
| | | * @param dirs |
| | | * @return |
| | | */ |
| | | public List<KeyValueEntity> selectDirsByTypes(String types, String dirs); |
| | | |
| | | /** |
| | | * 根据表名查询附件 |
| | | * |
| | | * @param tab 表名 |
| | |
| | | if (Character.isUpperCase(ch)) { |
| | | sb.append('_'); |
| | | sb.append(Character.toLowerCase(ch)); |
| | | }else { |
| | | } else { |
| | | sb.append(ch); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<KeyValueEntity> selectDirsByTypes(String types, String dirs) { |
| | | return baseQueryMapper.selectDirsByTypes(types, dirs); |
| | | } |
| | | |
| | | @Override |
| | | public List<AttachEntity> selectAnnexByTab(String tab, String gids) { |
| | | return baseQueryMapper.selectAnnexByTab(tab, gids); |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.lf.server.entity.ctrl.DownloadReqEntity; |
| | | import com.lf.server.entity.ctrl.KeyValueEntity; |
| | | import com.lf.server.entity.data.DownloadEntity; |
| | | import com.lf.server.entity.sys.AttachEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.io.File; |
| | | import java.util.*; |
| | |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class DataLibService { |
| | | @Autowired |
| | | PathHelper pathHelper; |
| | |
| | | return null; |
| | | } |
| | | |
| | | List<String> list = codesAsList(codes); |
| | | list = copeDirCodes(list); |
| | | List<String> list = Arrays.asList(codes.split(",")); |
| | | //List<String> list = codesAsList(codes); |
| | | //list = copeDirCodes(list); |
| | | setRightLike(list, field); |
| | | |
| | | return "(" + StringHelper.join(list, " or ") + ")"; |
| | | } |
| | | |
| | | /** |
| | | * 单位编码转集合 |
| | | * 单位编码转集合 * |
| | | */ |
| | | private static List<String> codesAsList(String codes) { |
| | | List<String> list = Arrays.asList(codes.split(",")); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 处理目录编码 |
| | | * 处理目录编码 * |
| | | */ |
| | | private static List<String> copeDirCodes(List<String> list) { |
| | | List<String> prjList = getDirCodesByLen(list, 0, 2); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 根据长度获取单位编码 |
| | | * 根据长度获取单位编码 * |
| | | */ |
| | | private static List<String> getDirCodesByLen(List<String> list, int start, int end) { |
| | | List<String> rs = new ArrayList<>(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 过滤项目编码 |
| | | * 过滤项目编码 * |
| | | */ |
| | | private static List<String> filterCodes(List<String> prjList, List<String> appList) { |
| | | int i = 0; |
| | |
| | | * 设置 右like |
| | | */ |
| | | private static void setRightLike(List<String> list, String field) { |
| | | if (list.isEmpty()) { |
| | | /*if (list.isEmpty()) { |
| | | list.add("1 = 2"); |
| | | return; |
| | | } |
| | | }*/ |
| | | |
| | | for (int i = 0, c = list.size(); i < c; i++) { |
| | | String str = String.format("%s like '%s%%'", field, list.get(i)); |
| | | list.set(i, str); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据资料类别获取目录编码 |
| | | */ |
| | | public String getDirsByTypes(String types, String dirs, String field) { |
| | | if (StringUtils.isEmpty(types) && StringUtils.isEmpty(dirs)) { |
| | | return null; |
| | | } |
| | | |
| | | if (!StringUtils.isEmpty(types)) { |
| | | List<KeyValueEntity> list = baseQueryService.selectDirsByTypes(types, dirs); |
| | | if (null == list || list.isEmpty()) { |
| | | return null; |
| | | } |
| | | |
| | | return copeDirs(list, field); |
| | | } |
| | | |
| | | return copeCodes(dirs, field); |
| | | } |
| | | |
| | | /** |
| | | * 处理目录编码 |
| | | */ |
| | | public static String copeDirs(List<KeyValueEntity> kvs, String field) { |
| | | List<String> list = new ArrayList<>(); |
| | | for (KeyValueEntity kv : kvs) { |
| | | String[] dirs = kv.getValue().split(","); |
| | | for (String dir : dirs) { |
| | | list.add(String.format("%s like '%s%%'", field, dir)); |
| | | } |
| | | } |
| | | |
| | | return "(" + StringHelper.join(list, " or ") + ")"; |
| | | } |
| | | } |
| | |
| | | order by key |
| | | </select> |
| | | |
| | | <select id="selectDirsByTypes" resultType="com.lf.server.entity.ctrl.KeyValueEntity"> |
| | | select (select string_agg(code, ',') from lf.sys_dir where name = a.name) "key", name "value" |
| | | from lf.sys_dir a |
| | | <where> |
| | | 1 = 1 |
| | | <if test="types != null"> |
| | | and name in |
| | | <foreach item="type" collection="types" open="(" separator="," close=")"> |
| | | #{type} |
| | | </foreach> |
| | | </if> |
| | | <if test="dirs != null"> |
| | | and ${dirs} |
| | | </if> |
| | | </where> |
| | | group by name |
| | | order by key |
| | | </select> |
| | | |
| | | <select id="selectAnnexByTab" resultType="com.lf.server.entity.sys.AttachEntity"> |
| | | select a.* from lf.sys_attach a |
| | | <where> |