| | |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.all.StaticData; |
| | | import com.lf.server.entity.ctrl.DownloadReqEntity; |
| | | import com.lf.server.entity.ctrl.IdNameEntity; |
| | | import com.lf.server.entity.data.DictEntity; |
| | | import com.lf.server.entity.data.DownloadEntity; |
| | | import com.lf.server.entity.data.MetaEntity; |
| | | import com.lf.server.entity.data.VerEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.ClassHelper; |
| | | import com.lf.server.helper.Md5Helper; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.helper.WebHelper; |
| | | import com.lf.server.helper.*; |
| | | import com.lf.server.mapper.all.BasicMapper; |
| | | import com.lf.server.service.all.BaseQueryService; |
| | | import com.lf.server.service.data.DownloadService; |
| | | import com.lf.server.service.data.MetaService; |
| | | import com.lf.server.service.data.VerService; |
| | | import com.lf.server.service.show.CadService; |
| | | import com.lf.server.service.sys.DepService; |
| | | import com.lf.server.service.sys.DownlogService; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import io.swagger.annotations.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.net.URLDecoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @RestController |
| | | @RequestMapping("/meta") |
| | | public class MetaController extends BaseController { |
| | | @Autowired |
| | | @Resource |
| | | MetaService metaService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | TokenService tokenService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | BaseQueryService baseQueryService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | DownlogService downlogService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | DownloadService downloadService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | VerService verService; |
| | | |
| | | @Resource |
| | | DepService depService; |
| | | |
| | | @Resource |
| | | CadService cadService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询并返回记录数") |
| | |
| | | List<MetaEntity> rs = metaService.selectByPage(depcode, dircode, verid, name, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "根据GUID查询GDB") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "guid", value = "GUID", dataType = "String", paramType = "query", example = "d58e66d9606a4b85e7c8ab43b3db0b55") |
| | | }) |
| | | @GetMapping(value = "/selectGdbByGuid") |
| | | public ResponseMsg<Object> selectGdbByGuid(String guid) { |
| | | try { |
| | | if (StringHelper.isEmpty(guid)) { |
| | | return fail("文件GUID值不能为空", null); |
| | | } |
| | | |
| | | List<MetaEntity> rs = metaService.selectGdbByGuid(guid); |
| | | |
| | | return success(null == rs ? 0 : rs.size(), rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询Dwg转换") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "元数据ID", dataType = "int", paramType = "query", example = "7715") |
| | | }) |
| | | @GetMapping(value = "/selectConvertToDwg") |
| | | public ResponseMsg<Object> selectConvertToDwg(int id) { |
| | | try { |
| | | String rs = cadService.convert(id); |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "插入一条") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "entity", value = "实体类", dataType = "MetaEntity", paramType = "body") |
| | |
| | | return fail("用户未登录", null); |
| | | } |
| | | |
| | | int count = downloadService.selectCountForUser(ue.getId(), 3, name); |
| | | int count = downloadService.selectCountForUser(ue.getId(), "3,4", name); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | List<DownloadEntity> rs = downloadService.selectByPageForUser(ue.getId(), 3, name, pageSize, pageSize * (pageIndex - 1)); |
| | | List<DownloadEntity> rs = downloadService.selectByPageForUser(ue.getId(), "3,4", name, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "请求下载") |
| | | @ApiOperation(value = "查询元数据中溢出的单位ID") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "pwd", value = "密码", dataType = "String", paramType = "body", example = ""), |
| | | @ApiImplicitParam(name = "ids", value = "ID数组", dataType = "Integer", paramType = "body", example = "1,2") |
| | | @ApiImplicitParam(name = "reqEntity", value = "请求下载实体", dataType = "DownloadReqEntity", paramType = "body") |
| | | }) |
| | | @ResponseBody |
| | | @PostMapping(value = "/downloadReq") |
| | | public ResponseMsg<Object> downloadReq(@RequestBody DownloadReqEntity reqEntity, HttpServletRequest req, HttpServletResponse res) { |
| | | @PostMapping(value = "/selectMetaOverflowDep") |
| | | public ResponseMsg<Object> selectMetaOverflowDep(@RequestBody DownloadReqEntity dr, HttpServletRequest req, HttpServletResponse res) { |
| | | try { |
| | | if (null == reqEntity || StringHelper.isEmpty(reqEntity.getPwd())) { |
| | | return fail("密码不能为空"); |
| | | } |
| | | if (null == reqEntity.getIds() || reqEntity.getIds().isEmpty()) { |
| | | return fail("请选择要下载的文件"); |
| | | } |
| | | if (!DownloadService.decryptPwd(reqEntity)) { |
| | | return fail("密码解密失败", null); |
| | | } |
| | | if (StringHelper.isPwdInvalid(reqEntity.getPwd())) { |
| | | return fail("密码不符合要求"); |
| | | } |
| | | |
| | | List<MetaEntity> list = metaService.selectMetaFiles(reqEntity.getIds()); |
| | | if (null == list || list.isEmpty()) { |
| | | return fail("没有找到元数据"); |
| | | if (null == dr || null == dr.getIds() || dr.getIds().isEmpty()) { |
| | | return fail("请选择要下载的文件ID"); |
| | | } |
| | | |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | String guid = downloadService.zipFiles(ue, list, reqEntity.getPwd()); |
| | | if (StaticData.ADMIN.equals(ue.getUid())) { |
| | | return success(new ArrayList<String>()); |
| | | } |
| | | |
| | | List<String> list = metaService.selectMetaOverflowDep(ue, dr); |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "根据单位编码数组查询单位") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "codes", value = "单位编码数组", dataType = "String", paramType = "query", allowMultiple = true, example = "00,0001") |
| | | }) |
| | | @GetMapping(value = "/selectDepsByCodes") |
| | | public ResponseMsg<Object> selectDepsByCodes(String[] codes) { |
| | | try { |
| | | if (null == codes || codes.length == 0) { |
| | | return fail("单位ID集合为空"); |
| | | } |
| | | |
| | | List<IdNameEntity> list = depService.selectDepsByCodes(codes); |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "请求元数据下载") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "dr", value = "请求下载实体类", dataType = "DownloadReqEntity", paramType = "body") |
| | | }) |
| | | @ResponseBody |
| | | @PostMapping(value = "/downloadReq") |
| | | public ResponseMsg<Object> downloadReq(@RequestBody DownloadReqEntity dr, HttpServletRequest req, HttpServletResponse res) { |
| | | try { |
| | | if (null == dr || StringHelper.isEmpty(dr.getPwd())) { |
| | | return fail("密码不能为空"); |
| | | } |
| | | if (null == dr.getIds() || dr.getIds().isEmpty()) { |
| | | return fail("请选择要下载的文件ID"); |
| | | } |
| | | if (!DownloadService.decryptPwd(dr)) { |
| | | return fail("密码解密失败", null); |
| | | } |
| | | if (StringHelper.isPwdInvalid(dr.getPwd())) { |
| | | return fail("密码不符合要求"); |
| | | } |
| | | |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | String guid = metaService.downloadMeteReq(ue, dr); |
| | | |
| | | return success(guid); |
| | | } catch (Exception ex) { |