|
@@ -0,0 +1,139 @@
|
|
|
|
+package com.onemap.apply.service.impl.project;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.onemap.apply.domain.project.TProjectBasic;
|
|
|
|
+import com.onemap.apply.domain.project.TProjectModel;
|
|
|
|
+import com.onemap.apply.domain.yzt.PoiSearchDTO;
|
|
|
|
+import com.onemap.apply.mapper.project.ProjectBasicMapper;
|
|
|
|
+import com.onemap.apply.mapper.project.ProjectModelMapper;
|
|
|
|
+import com.onemap.apply.service.project.IProjectService;
|
|
|
|
+import com.onemap.apply.utils.UnPackageUtils;
|
|
|
|
+import com.onemap.common.core.web.domain.RequestResult;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
+
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+@Service
|
|
|
|
+public class ProjectServiceImpl implements IProjectService {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ProjectBasicMapper projectBasicMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ProjectModelMapper projectModelMapper;
|
|
|
|
+ @Value("${tempath}")
|
|
|
|
+ private String tempath;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public RequestResult list(PoiSearchDTO poiSearchDTO) {
|
|
|
|
+ try {
|
|
|
|
+ Map data = new HashMap();
|
|
|
|
+ Integer count = projectBasicMapper.count(poiSearchDTO.getName(), poiSearchDTO.getType());
|
|
|
|
+ data.put("count", count);
|
|
|
|
+ List<TProjectBasic> res = projectBasicMapper.list(poiSearchDTO.getName(), poiSearchDTO.getType(), poiSearchDTO.getLimit(), poiSearchDTO.getOffset());
|
|
|
|
+ for (int i = 0; i < res.size(); i++) {
|
|
|
|
+ List<TProjectModel> model = projectBasicMapper.listmodel(res.get(i).getXmbh());
|
|
|
|
+ res.get(i).setModel(model);
|
|
|
|
+ }
|
|
|
|
+ data.put("data", res);
|
|
|
|
+ return RequestResult.success("查询成功!", data);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ return RequestResult.error("查询失败!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public RequestResult updateShzt(String xmbh, String shzt) {
|
|
|
|
+ try {
|
|
|
|
+ projectBasicMapper.updateShzt(xmbh.split(","), shzt);
|
|
|
|
+ return RequestResult.success("更新成功!", 1);
|
|
|
|
+ } catch (Exception r) {
|
|
|
|
+ r.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ return RequestResult.error("更新失败!", 0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public RequestResult importModel(TProjectModel tProjectModel) {
|
|
|
|
+ if (tProjectModel == null) {
|
|
|
|
+ return RequestResult.error("参数为空!");
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ projectModelMapper.insert(tProjectModel);
|
|
|
|
+ return RequestResult.success("导入成功!", 1);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ return RequestResult.error("导入失败!", 0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public RequestResult uploadModelFile(MultipartFile file) {
|
|
|
|
+ //获得文件名称
|
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
|
+ //获得文件后缀名
|
|
|
|
+ String type = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
|
|
|
|
+ //判断上传的是否是压缩包
|
|
|
|
+ if (!type.equals("zip") && !type.equals("rar")) {
|
|
|
|
+ return RequestResult.error("请上传压缩包", null);
|
|
|
|
+ }
|
|
|
|
+ File dest = new File(tempath + "/" + fileName);
|
|
|
|
+ //获得上级目录
|
|
|
|
+ File dir = dest.getParentFile();
|
|
|
|
+ if (!dir.exists()) {
|
|
|
|
+ dir.mkdirs();
|
|
|
|
+ }
|
|
|
|
+ //获取当前时间的时间戳
|
|
|
|
+ long timeMillis = System.currentTimeMillis();
|
|
|
|
+ String filePath = "";
|
|
|
|
+ try {
|
|
|
|
+ //上传文件
|
|
|
|
+ file.transferTo(dest);
|
|
|
|
+ //解压zip格式
|
|
|
|
+ if (type.equals("zip")) {
|
|
|
|
+ new UnPackageUtils().unPackZip(dest, tempath + "/" + timeMillis);
|
|
|
|
+ } else {
|
|
|
|
+ //解压rar格式
|
|
|
|
+ new UnPackageUtils().unPackRar(dest, tempath + "/" + timeMillis);
|
|
|
|
+ }
|
|
|
|
+ File[] files = new File(tempath + "/" + timeMillis).listFiles();
|
|
|
|
+ for (File file1 : files) {
|
|
|
|
+ if (file1.getAbsolutePath().substring(file1.getAbsolutePath().lastIndexOf(".") + 1).toLowerCase().equals("max")) {
|
|
|
|
+ filePath = file1.getAbsolutePath();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!"".equals(filePath)) {
|
|
|
|
+ return RequestResult.success("上传成功", filePath);
|
|
|
|
+ } else {
|
|
|
|
+ return RequestResult.error("未检索到.max文件");
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ return RequestResult.error("上传失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public RequestResult deleteModel(String id) {
|
|
|
|
+ try{
|
|
|
|
+ QueryWrapper<TProjectModel> wrapper = new QueryWrapper<>();
|
|
|
|
+ wrapper.eq("bsm", id);
|
|
|
|
+ projectModelMapper.delete(wrapper);
|
|
|
|
+ return RequestResult.success("删除成功", 1);
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ return RequestResult.error("删除失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|