瀏覽代碼

检查文件分片信息、分片上传成果包、合包并提交成果相关接口提交,有待完善

wanger 5 月之前
父節點
當前提交
c133806d19

+ 40 - 9
onemap-modules/onemap-api/src/main/java/com/onemap/api/controller/ResultsController.java

@@ -2,31 +2,62 @@ package com.onemap.api.controller;
 
 
 import com.onemap.api.domain.CghjQxcgsbrwIoDto;
+import com.onemap.api.domain.CompleteParams;
 import com.onemap.api.service.ResultsService;
 import com.onemap.common.core.web.controller.BaseController;
 import com.onemap.common.core.web.domain.RequestResult;
+import oracle.ucp.proxy.annotation.Post;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
 
 /**
- * 智慧选址接口
+ * 规划成果包接口
  *
  * @author onemap
  */
-@RequestMapping("/open/results/md5")
+@RequestMapping("/open/results")
 @RestController
 public class ResultsController extends BaseController {
     @Autowired
     private ResultsService ResultsService;
 
-    @PostMapping("/md5")
-    public RequestResult md5(@RequestBody CghjQxcgsbrwIoDto cghjQxcgsbrwIoDto, HttpServletRequest request) {
-        return ResultsService.md5(cghjQxcgsbrwIoDto, request);
+    /**
+     * 检查文件分片信息
+     *
+     * @param allParams
+     * @return
+     */
+    @GetMapping("/md5")
+    public RequestResult md5(@RequestParam Map<String, Object> allParams) {
+        return ResultsService.md5(allParams);
+    }
+
+    /**
+     * 分片上传成果包
+     *
+     * @param md5
+     * @param chunk
+     * @param file
+     * @return
+     */
+    @PostMapping("/upload")
+    public RequestResult upload(String md5, Integer chunk, MultipartFile file) {
+        return ResultsService.upload(md5, chunk, file);
+    }
+
+    /**
+     * 合包并提交成果
+     *
+     * @param completeParams
+     * @return
+     */
+    @PostMapping("/complete")
+    public RequestResult complete(@RequestBody CompleteParams completeParams) {
+        return ResultsService.complete(completeParams);
     }
 
 }

+ 31 - 9
onemap-modules/onemap-api/src/main/java/com/onemap/api/domain/CghjQxcgsbrwIoDto.java

@@ -4,26 +4,48 @@ public class CghjQxcgsbrwIoDto {
 
     private String md5;
     private int size;
-    private boolean New=false;
+    private boolean New = false;
 
     private String appid;
     private String ghlx;
 
-    public String getMd5() {return md5;}
-    public void setMd5(String md5) {this.md5 = md5;}
+    public String getMd5() {
+        return md5;
+    }
+
+    public void setMd5(String md5) {
+        this.md5 = md5;
+    }
+
+    public int getSize() {
+        return size;
+    }
+
+    public void setSize(int size) {
+        this.size = size;
+    }
 
-    public int getSize() {return size;}
-    public void setSize(int size) {this.size = size;}
+    public boolean getNew() {
+        return New;
+    }
 
-    public boolean getNew() {return New;}
-    public void setNew() {this.New = New;}
+    public void setNew() {
+        this.New = New;
+    }
 
     public String getAppid() {
         return appid;
     }
+
     public void setAppid(String appid) {
         this.appid = appid;
     }
-    public String getGhlx() {return ghlx;}
-    public void setGhlx(String ghlx) {this.ghlx = ghlx;}
+
+    public String getGhlx() {
+        return ghlx;
+    }
+
+    public void setGhlx(String ghlx) {
+        this.ghlx = ghlx;
+    }
 }

+ 52 - 0
onemap-modules/onemap-api/src/main/java/com/onemap/api/domain/CompleteParams.java

@@ -0,0 +1,52 @@
+package com.onemap.api.domain;
+
+/**
+ * 合包请求参数
+ */
+public class CompleteParams {
+    private String md5;//文件md5值
+    private String filename;//文件名(带后缀“.zip”)
+    private String type;//成果类型(0新上传 1更新)
+    private String reason;//当成果类型为1时需要填写更新原因
+    private String instid;//流程主键(补正流程需要)
+
+    public String getMd5() {
+        return md5;
+    }
+
+    public void setMd5(String md5) {
+        this.md5 = md5;
+    }
+
+    public String getFilename() {
+        return filename;
+    }
+
+    public void setFilename(String filename) {
+        this.filename = filename;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getReason() {
+        return reason;
+    }
+
+    public void setReason(String reason) {
+        this.reason = reason;
+    }
+
+    public String getInstid() {
+        return instid;
+    }
+
+    public void setInstid(String instid) {
+        this.instid = instid;
+    }
+}

+ 123 - 0
onemap-modules/onemap-api/src/main/java/com/onemap/api/domain/Qxcgsbrw.java

@@ -0,0 +1,123 @@
+package com.onemap.api.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+@TableName("t_cghj_qxcgsbrw")
+public class Qxcgsbrw {
+    public String bsm;
+    public String xmmc;
+    public String xzqdm;
+    public String xzqmc;
+    public Integer total;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    public Date time;
+    public Integer rwzt;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    public Date hjsj;
+    public String cgwj;
+    public String cglj;
+    public String bz;
+    public String ghlx;
+
+    public String getBsm() {
+        return bsm;
+    }
+
+    public void setBsm(String bsm) {
+        this.bsm = bsm;
+    }
+
+    public String getXmmc() {
+        return xmmc;
+    }
+
+    public void setXmmc(String xmmc) {
+        this.xmmc = xmmc;
+    }
+
+    public String getXzqdm() {
+        return xzqdm;
+    }
+
+    public void setXzqdm(String xzqdm) {
+        this.xzqdm = xzqdm;
+    }
+
+    public String getXzqmc() {
+        return xzqmc;
+    }
+
+    public void setXzqmc(String xzqmc) {
+        this.xzqmc = xzqmc;
+    }
+
+    public Integer getTotal() {
+        return total;
+    }
+
+    public void setTotal(Integer total) {
+        this.total = total;
+    }
+
+    public Date getTime() {
+        return time;
+    }
+
+    public void setTime(Date time) {
+        this.time = time;
+    }
+
+    public Integer getRwzt() {
+        return rwzt;
+    }
+
+    public void setRwzt(Integer rwzt) {
+        this.rwzt = rwzt;
+    }
+
+    public Date getHjsj() {
+        return hjsj;
+    }
+
+    public void setHjsj(Date hjsj) {
+        this.hjsj = hjsj;
+    }
+
+    public String getCgwj() {
+        return cgwj;
+    }
+
+    public void setCgwj(String cgwj) {
+        this.cgwj = cgwj;
+    }
+
+    public String getCglj() {
+        return cglj;
+    }
+
+    public void setCglj(String cglj) {
+        this.cglj = cglj;
+    }
+
+    public String getBz() {
+        return bz;
+    }
+
+    public void setBz(String bz) {
+        this.bz = bz;
+    }
+
+    public String getGhlx() {
+        return ghlx;
+    }
+
+    public void setGhlx(String ghlx) {
+        this.ghlx = ghlx;
+    }
+}

+ 58 - 0
onemap-modules/onemap-api/src/main/java/com/onemap/api/domain/Qxcgsbrwfp.java

@@ -0,0 +1,58 @@
+package com.onemap.api.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+@TableName("t_cghj_qxcgsbrwfp")
+public class Qxcgsbrwfp {
+    public String bsm;
+    public String md5;
+    public Integer chunk;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    public Date scsj;
+    public String path;
+
+    public String getBsm() {
+        return bsm;
+    }
+
+    public void setBsm(String bsm) {
+        this.bsm = bsm;
+    }
+
+    public String getMd5() {
+        return md5;
+    }
+
+    public void setMd5(String md5) {
+        this.md5 = md5;
+    }
+
+    public Integer getChunk() {
+        return chunk;
+    }
+
+    public void setChunk(Integer chunk) {
+        this.chunk = chunk;
+    }
+
+    public Date getScsj() {
+        return scsj;
+    }
+
+    public void setScsj(Date scsj) {
+        this.scsj = scsj;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+}

+ 27 - 0
onemap-modules/onemap-api/src/main/java/com/onemap/api/domain/Rwzt.java

@@ -0,0 +1,27 @@
+package com.onemap.api.domain;
+
+/**
+ * 旗县成果汇交任务状态
+ */
+public class Rwzt {
+    public Integer cj = 0;
+    public Integer whb = 1;
+    public Integer wc = 2;
+    public Integer hbsb = 3;
+
+    public Integer getCj() {
+        return cj;
+    }
+
+    public Integer getWhb() {
+        return whb;
+    }
+
+    public Integer getWc() {
+        return wc;
+    }
+
+    public Integer getHbsb() {
+        return hbsb;
+    }
+}

+ 15 - 0
onemap-modules/onemap-api/src/main/java/com/onemap/api/mapper/QxcgsbrwMapper.java

@@ -0,0 +1,15 @@
+package com.onemap.api.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.onemap.api.domain.Qxcgsbrw;
+import com.onemap.api.domain.TSysOpenUser;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 数据层
+ *
+ * @author onemap
+ */
+public interface QxcgsbrwMapper extends BaseMapper<Qxcgsbrw> {
+    void deleteByMd5(@Param("md5") String md5);
+}

+ 20 - 0
onemap-modules/onemap-api/src/main/java/com/onemap/api/mapper/QxcgsbrwfpMapper.java

@@ -0,0 +1,20 @@
+package com.onemap.api.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.onemap.api.domain.Qxcgsbrw;
+import com.onemap.api.domain.Qxcgsbrwfp;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 数据层
+ *
+ * @author onemap
+ */
+public interface QxcgsbrwfpMapper extends BaseMapper<Qxcgsbrwfp> {
+    void deleteByMd5(@Param("md5") String md5);
+
+    List<Integer> selectChunksByMd5(@Param("md5") String md5);
+
+}

+ 8 - 1
onemap-modules/onemap-api/src/main/java/com/onemap/api/service/ResultsService.java

@@ -1,11 +1,18 @@
 package com.onemap.api.service;
 
 import com.onemap.api.domain.CghjQxcgsbrwIoDto;
+import com.onemap.api.domain.CompleteParams;
 import com.onemap.common.core.web.domain.RequestResult;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
 
 public interface ResultsService {
 
-    RequestResult md5(CghjQxcgsbrwIoDto cghjQxcgsbrwIoDto, HttpServletRequest request);
+    RequestResult md5(Map<String, Object> allParams);
+
+    RequestResult upload(String md5, Integer chunk, MultipartFile file);
+
+    RequestResult complete(CompleteParams completeParams);
 }

+ 2 - 27
onemap-modules/onemap-api/src/main/java/com/onemap/api/service/impl/ResultSearchServiceImpl.java

@@ -13,6 +13,8 @@ import org.springframework.stereotype.Service;
 import javax.servlet.http.HttpServletResponse;
 import java.util.*;
 
+import static com.onemap.api.util.utils.getPlanType;
+
 
 @Service
 public class ResultSearchServiceImpl implements ResultSearchService {
@@ -225,33 +227,6 @@ public class ResultSearchServiceImpl implements ResultSearchService {
         return reStrMd5;
     }
 
-    /**
-     * 通过规划类型转自治区需要的整型数据
-     *
-     * @param ghlx 规划类型
-     * @return
-     */
-    public Integer getPlanType(String ghlx) {
-        switch (ghlx) {
-            case "总体规划":
-                return 1;
-            case "村庄规划":
-                return 2;
-            case "报批项目":
-                return 3;
-            case "总体规划(对部)":
-                return 4;
-            case "详细规划":
-                return 5;
-            case "专项规划":
-                return 6;
-            case "乡镇苏木国土空间规划":
-                return 7;
-            default:
-                return 1;
-        }
-    }
-
     /**
      * 调用接口统一获取token
      *

+ 215 - 13
onemap-modules/onemap-api/src/main/java/com/onemap/api/service/impl/ResultsServiceImpl.java

@@ -1,9 +1,10 @@
 package com.onemap.api.service.impl;
 
+import ch.qos.logback.core.util.FileUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.onemap.api.domain.CghjQxcgsbrwIoDto;
-import com.onemap.api.domain.AuthorizeDto;
-import com.onemap.api.domain.TSysOpenUser;
+import com.onemap.api.domain.*;
+import com.onemap.api.mapper.QxcgsbrwMapper;
+import com.onemap.api.mapper.QxcgsbrwfpMapper;
 import com.onemap.api.mapper.TSysOpenUserMapper;
 import com.onemap.api.service.ResultsService;
 import com.onemap.common.core.constant.SecurityConstants;
@@ -11,12 +12,26 @@ import com.onemap.common.core.domain.R;
 import com.onemap.common.core.utils.StringUtils;
 import com.onemap.common.core.web.domain.RequestResult;
 import com.onemap.common.security.service.TokenService;
+import com.onemap.common.security.utils.SecurityUtils;
 import com.onemap.system.api.RemoteUserService;
+import org.apache.commons.io.FileUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.Map;
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Array;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+import static com.onemap.api.util.Md5Utils.getMD5;
+import static com.onemap.api.util.utils.*;
 
 
 @Service
@@ -25,23 +40,210 @@ public class ResultsServiceImpl implements ResultsService {
     @Autowired
     private TSysOpenUserMapper tSysOpenUserMapper;
     @Autowired
-    private RemoteUserService remoteUserService;
+    private QxcgsbrwMapper qxcgsbrwMapper;
     @Autowired
-    private TokenService tokenService;
+    private QxcgsbrwfpMapper qxcgsbrwfpMapper;
+    private Rwzt rwzt = new Rwzt();
+    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+    @Value("${Cggl.temp}")
+    private String tempfolder;
 
+    @Transactional(rollbackFor = Exception.class)
     @Override
-    public RequestResult md5(CghjQxcgsbrwIoDto cghjQxcgsbrwIoDto, HttpServletRequest request) {
-        String appid = cghjQxcgsbrwIoDto.getAppid();
-
+    public RequestResult md5(Map<String, Object> allParams) {
+        try {
+            //TODO wanger 获取参数
+            if (allParams.get("md5") == null) {
+                return RequestResult.error("文件MD5参数不能为空");
+            } else if (allParams.get("size") == null) {
+                return RequestResult.error("文件分片总数量参数不能为空");
+            }
+            Boolean isnew = false;
+            if (allParams.get("new") != null) {
+                isnew = Boolean.valueOf(String.valueOf(allParams.get("new")));
+            }
+            Integer size = Integer.valueOf(String.valueOf(allParams.get("size")));
+            String md5 = String.valueOf(allParams.get("md5"));
+            TSysOpenUser user = getOpenUser();
+            if (user == null) {
+                return RequestResult.error("非法用户!");
+            }
+            Integer ghlx = 1;
+            if (allParams.get("ghlx") != null) {
+                String lx = String.valueOf(allParams.get("ghlx"));
+                ghlx = getPlanTypeForSj(lx);
+                if (ghlx == 0) {
+                    return RequestResult.error("规划类型参数错误!");
+                }
+            }
+            String folder = String.format("%s旗县成果上报\\%s\\%s\\%s\\", tempfolder, user.getXzqdm(), ghlx, md5);
+            loginfo(folder);
+            File curFile = new File(folder);
+            if (isnew) {
+                qxcgsbrwMapper.deleteByMd5(md5);
+                qxcgsbrwfpMapper.deleteByMd5(md5);
+                FileUtils.deleteDirectory(curFile);
+            }
+            makedir(folder);
+            //判断成果包是否存在
+            QueryWrapper<Qxcgsbrw> sbrwwrapper = new QueryWrapper<>();
+            sbrwwrapper.eq("bsm", md5);
+            Qxcgsbrw qxsbcg = qxcgsbrwMapper.selectOne(sbrwwrapper);
+            List<Integer> chunks = new ArrayList<>();
+            Date time = new Date();
+            if (qxsbcg == null) {//新的数据包
+                loginfo("新创建的任务");
+                Qxcgsbrw newRw = new Qxcgsbrw();
+                newRw.setBsm(md5);
+                newRw.setGhlx(String.valueOf(ghlx));
+                newRw.setTotal(size);
+                newRw.setXzqdm(user.getXzqdm());
+                newRw.setXzqmc(user.getXzqmc());
+                newRw.setRwzt(rwzt.getCj());
+                newRw.setTime(new Date());
+                qxcgsbrwMapper.insert(newRw);
+            } else {//已存在的数据包
+                loginfo("已创建过的任务");
+                time = qxsbcg.getTime();
+                chunks = qxcgsbrwfpMapper.selectChunksByMd5(md5);
+            }
+            Map<String, Object> res = new HashMap<>();
+            res.put("size", size);
+            res.put("chunks", chunks);
+            res.put("time", sdf.format(time));
+            loginfo("md5接口请求成功!");
+            return RequestResult.success("操作成功", res);
+        } catch (Exception e) {
+            e.printStackTrace();
+            loginfo("md5接口请求失败!");
+        }
+        return RequestResult.error("操作失败");
+    }
 
-        if (cghjQxcgsbrwIoDto.getMd5() == null || cghjQxcgsbrwIoDto.getMd5().isEmpty()){
+    @Override
+    public RequestResult upload(String md5, Integer chunk, MultipartFile file) {
+        if (StringUtils.isEmpty(md5)) {
             return RequestResult.error("文件MD5参数不能为空");
+        } else if (chunk == null) {
+            return RequestResult.error("文件分片总数量参数不能为空");
+        } else if (file == null) {
+            return RequestResult.error("文件参数不能为空");
+        } else if (file.getSize() == 0) {
+            return RequestResult.error("文件上传失败(0kb),请重新上传");
+        }
+        try {
+            TSysOpenUser user = getOpenUser();
+            if (user == null) {
+                return RequestResult.error("未获取到登录用户信息");
+            }
+            QueryWrapper<Qxcgsbrw> sbrwwrapper = new QueryWrapper<>();
+            sbrwwrapper.eq("bsm", md5);
+            Qxcgsbrw qxsbcg = qxcgsbrwMapper.selectOne(sbrwwrapper);
+            if (qxsbcg == null) {
+                return RequestResult.error("上传分片文件前,请先调用【检查文件分片信息接口(/api/open/results/md5)】创建任务");
+            } else if (qxsbcg.getRwzt() == rwzt.getWc()) {
+                return RequestResult.error("当前成果已提交完成,不允许再次进行文件上传");
+            }
+            String folder = String.format("%s旗县成果上报\\%s\\%s\\%s\\", tempfolder, user.getXzqdm(), qxsbcg.getGhlx(), md5);
+            makedir(folder);
+            loginfo(folder);
+            String filename = file.getOriginalFilename();
+            try {
+                file.transferTo(Paths.get(folder + "\\" + filename));
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+            //TODO wanger 删除成果包分片表
+            QueryWrapper<Qxcgsbrwfp> wrapper = new QueryWrapper();
+            wrapper.eq("md5", md5);
+            wrapper.eq("chunk", chunk);
+            qxcgsbrwfpMapper.delete(wrapper);
+            //TODO wanger 添加成果包分片表
+            Qxcgsbrwfp qxcgsbrwfp = new Qxcgsbrwfp();
+            qxcgsbrwfp.setBsm(StringUtils.getUUID());
+            qxcgsbrwfp.setChunk(chunk);
+            qxcgsbrwfp.setMd5(md5);
+            qxcgsbrwfp.setScsj(new Date());
+            qxcgsbrwfp.setPath(folder + "" + filename);
+            qxcgsbrwfpMapper.insert(qxcgsbrwfp);
+            //TODO wanger 添加成果任务表
+            qxsbcg.setTime(new Date());
+            qxsbcg.setRwzt(rwzt.getWhb());
+            qxcgsbrwMapper.update(qxsbcg, sbrwwrapper);
+            return RequestResult.success("操作成功", 1);
+        } catch (Exception e) {
+            e.printStackTrace();
         }
+        return RequestResult.error("操作失败", 0);
+    }
 
-        if (cghjQxcgsbrwIoDto.getGhlx() == null || cghjQxcgsbrwIoDto.getGhlx().isEmpty()){
-            cghjQxcgsbrwIoDto.setGhlx("总体规划");
+    @Override
+    public RequestResult complete(CompleteParams completeParams) {
+        String md5 = completeParams.getMd5();
+        String filename = completeParams.getFilename();
+        String type = completeParams.getType();
+        String reason = completeParams.getReason();
+        String instid = completeParams.getInstid();
+        if (StringUtils.isEmpty(md5)) {
+            return RequestResult.error("文件MD5参数不能为空");
+        } else if ("1".equals(type) && StringUtils.isEmpty(reason)) {
+            return RequestResult.error("请填写更新原因");
+        } else if (StringUtils.isEmpty(filename)) {
+            return RequestResult.error("文件名称不能为空");
+        }
+        TSysOpenUser user = getOpenUser();
+        if (user == null) {
+            return RequestResult.error("未获取到登录用户信息");
+        }
+        QueryWrapper<Qxcgsbrw> sbrwwrapper = new QueryWrapper<>();
+        sbrwwrapper.eq("bsm", md5);
+        Qxcgsbrw qxsbcg = qxcgsbrwMapper.selectOne(sbrwwrapper);
+        if (qxsbcg == null) {
+            return RequestResult.error("合包前请先调用【检查文件分片信息接口(/api/open/results/md5)】创建任务");
+        } else if (qxsbcg.getRwzt() == rwzt.getWc()) {
+            return RequestResult.error("当前成果已提交完成,不允许再次进行文件上传");
+        }
+        QueryWrapper<Qxcgsbrwfp> fpwrapper = new QueryWrapper<>();
+        fpwrapper.eq("md5", md5);
+        List<Qxcgsbrwfp> fplist = qxcgsbrwfpMapper.selectList(fpwrapper);
+        if (fplist.size() == 0) {
+            return RequestResult.error("合包前请先调用【分片上传成果包接口(/api/open/results/Upload)】上传成果");
+        } else if (fplist.size() != qxsbcg.getTotal()) {
+            return RequestResult.error(String.format("成果分片总数(%s)与上传片文件数量(%s)不符", qxsbcg.getTotal(), fplist.size()));
         }
+        String folder = String.format("%s旗县成果上报\\%s\\%s\\%s\\", tempfolder, user.getXzqdm(), qxsbcg.getGhlx(), md5);
+        loginfo("准备合包:" + folder);
+        List<String> filelist = new ArrayList<>();
+        for (Qxcgsbrwfp cur : fplist) {
+            filelist.add(cur.getPath());
+        }
+        String targetfilepath = folder + "" + filename;
+        try {
+            mergeZipFiles(filelist, targetfilepath);
+            loginfo("完成合包:" + folder);
+        } catch (IOException e) {
+            e.printStackTrace();
+            return RequestResult.error("合包失败,没找到合包后的文件,请联系管理员");
+        }
+        File targetfile = new File(targetfilepath);
+        String fileMd5 = getMD5(targetfile);
+        if (!fileMd5.equals(md5)) {
+            return RequestResult.error("警告:文件的MD5不一致");
+        }
+        return RequestResult.success("操作成功", 1);
+    }
 
-        return RequestResult.success("");
+    /**
+     * 通过当前登录用户token获取openuser表信息
+     *
+     * @return
+     */
+    public TSysOpenUser getOpenUser() {
+        String username = SecurityUtils.getUsername();
+        QueryWrapper<TSysOpenUser> openUserWrapper = new QueryWrapper<>();
+        openUserWrapper.eq("name", username);
+        openUserWrapper.last(" and rownum = 1");
+        TSysOpenUser user = tSysOpenUserMapper.selectOne(openUserWrapper);
+        return user;
     }
 }

+ 115 - 0
onemap-modules/onemap-api/src/main/java/com/onemap/api/util/utils.java

@@ -0,0 +1,115 @@
+package com.onemap.api.util;
+
+import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * 公用工具类
+ */
+public class utils {
+    /**
+     * 自治区成果包查询需要的plantype
+     *
+     * @param ghlx
+     * @return
+     */
+    public static Integer getPlanType(String ghlx) {
+        switch (ghlx) {
+            case "总体规划":
+                return 1;
+            case "村庄规划":
+                return 2;
+            case "报批项目":
+                return 3;
+            case "总体规划(对部)":
+                return 4;
+            case "详细规划":
+                return 5;
+            case "专项规划":
+                return 6;
+            case "乡镇苏木国土空间规划":
+                return 7;
+            default:
+                return 1;
+        }
+    }
+
+    /**
+     * 市级成果接口需要的plantype
+     *
+     * @param ghlx
+     * @return
+     */
+    public static Integer getPlanTypeForSj(String ghlx) {
+        switch (ghlx) {
+            case "评估成果":
+                return 1;
+            case "规划成果":
+                return 2;
+            case "总体规划":
+                return 3;
+            case "详细规划":
+                return 4;
+            case "专项规划":
+                return 5;
+            case "报批项目":
+                return 6;
+            case "苏木乡镇规划":
+                return 7;
+            case "城市更新":
+                return 8;
+            case "村庄规划":
+                return 9;
+            default:
+                return 0;
+        }
+    }
+
+    /**
+     * 判断文件夹是否存在,不存在则创建
+     *
+     * @param folderpath
+     */
+    public static void makedir(String folderpath) {
+        File folderFile = new File(folderpath);
+        if (!folderFile.exists()) {
+            try {
+                Files.createDirectories(Paths.get(folderpath));
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    /**
+     * 控制台打印
+     *
+     * @param info
+     */
+    public static void loginfo(String info) {
+        System.out.println(info);
+    }
+
+    /**
+     * 合并zip分片数据包
+     *
+     * @param fileNames
+     * @param outputFileName
+     * @throws IOException
+     */
+    public static void mergeZipFiles(List<String> fileNames, String outputFileName) throws IOException {
+        FileOutputStream fos = new FileOutputStream(outputFileName);
+        for (String fileName : fileNames) {
+            File cur = new File(fileName);
+            byte[] buffer = Files.readAllBytes(Paths.get(fileName));
+            fos.write(buffer, 0, buffer.length);
+        }
+        fos.flush();
+        fos.close();
+    }
+}

+ 6 - 1
onemap-modules/onemap-api/src/main/resources/bootstrap.yml

@@ -3,7 +3,12 @@ server:
   port: 9209
 
 # Spring
-spring: 
+spring:
+  servlet:
+    multipart:
+      enabled: true
+      max-file-size: 10240MB
+      max-request-size: 10240MB
   application:
     # 应用名称
     name: onemap-api

+ 12 - 0
onemap-modules/onemap-api/src/main/resources/mapper/QxcgsbrwMapper.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.onemap.api.mapper.QxcgsbrwMapper">
+
+
+    <delete id="deleteByMd5" parameterType="java.lang.String">
+        delete from t_cghj_qxcgsbrw where bsm = #{md5}
+    </delete>
+
+</mapper>

+ 16 - 0
onemap-modules/onemap-api/src/main/resources/mapper/QxcgsbrwfpMapper.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.onemap.api.mapper.QxcgsbrwfpMapper">
+
+
+    <delete id="deleteByMd5" parameterType="java.lang.String">
+        delete from t_cghj_qxcgsbrwfp where md5 = #{md5}
+    </delete>
+
+    <select id="selectChunksByMd5" parameterType="java.lang.String" resultType="java.lang.Integer">
+        select chunk from T_CGHJ_QXCGSBRWFP t where md5 = #{md5} order by chunk
+    </select>
+
+</mapper>