| | |
| | | |
| | | 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); |
| | | setRightLike(list, field); |
| | | //List<String> list = Arrays.asList(codes.split(",")); |
| | | //List<String> list = codesAsList(codes); |
| | | //list = copeDirCodes(list); |
| | | //setRightLike(list, field); |
| | | |
| | | return "(" + StringHelper.join(list, " or ") + ")"; |
| | | //return "(" + StringHelper.join(list, " or ") + ")"; |
| | | |
| | | List<String> list = new ArrayList<>(); |
| | | for (String dir : codes.split(",")) { |
| | | list.add("^" + dir); |
| | | } |
| | | |
| | | return field + " ~ '" + StringHelper.join(list, "|") + "'"; |
| | | } |
| | | |
| | | /** |
| | | * 单位编码转集合 |
| | | * 单位编码转集合 * |
| | | */ |
| | | 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 |
| | | * 设置 右like * |
| | | */ |
| | | private static void setRightLike(List<String> list, String field) { |
| | | if (list.isEmpty()) { |
| | |
| | | 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.split(","), copeCodes(dirs, "code")); |
| | | if (null == list || list.isEmpty()) { |
| | | return "1 = 2"; |
| | | } |
| | | |
| | | return copeDirs(list, field); |
| | | } |
| | | |
| | | return copeCodes(dirs, field); |
| | | } |
| | | |
| | | /** |
| | | * 处理目录编码:dircode ~ '^0A|^0E' |
| | | */ |
| | | 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("^" + dir); |
| | | } |
| | | } |
| | | |
| | | return field + " ~ '" + StringHelper.join(list, "|") + "'"; |
| | | } |
| | | } |