Commit a642344f by 宋珺琪

审批接口调整、上传下载word文件

parent cec2c81e
...@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableName; ...@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
/** /**
*@ClassName: TbstApprovePzxx *@ClassName: TbstApprovePzxx
...@@ -26,7 +28,7 @@ public class TbstApprovePzxx { ...@@ -26,7 +28,7 @@ public class TbstApprovePzxx {
private String asjbh; private String asjbh;
@ApiModelProperty(value = "案件类别") @ApiModelProperty(value = "案件类别")
@TableField("AJLB") @TableField("AJLB")
private String ajlb; private String ajlb; //刑事案件01 行政案件02 重点人员03 大数据建模05 其他04
@ApiModelProperty(value = "文件名") @ApiModelProperty(value = "文件名")
@TableField("FILENAME") @TableField("FILENAME")
private String filename; private String filename;
...@@ -88,4 +90,12 @@ public class TbstApprovePzxx { ...@@ -88,4 +90,12 @@ public class TbstApprovePzxx {
private int end; //结束行数 private int end; //结束行数
@ApiModelProperty(value = "文件")
@TableField("WORDFILE")
private byte[] wordFile;
@ApiModelProperty(value = "文件名")
@TableField("WORD_NAME")
private String wordName;
} }
...@@ -48,6 +48,12 @@ ...@@ -48,6 +48,12 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>3.8</version>
</dependency>
<dependency>
<groupId>com.car</groupId> <groupId>com.car</groupId>
<artifactId>sdkApi</artifactId> <artifactId>sdkApi</artifactId>
<version>RELEASE</version> <version>RELEASE</version>
......
...@@ -32,18 +32,17 @@ public class AsjxxSelectController { ...@@ -32,18 +32,17 @@ public class AsjxxSelectController {
/** /**
* 通过案事件编号或接警编号查询案事件信息 * 通过案事件编号或接警编号查询案事件信息
* @param queryBh * @param queryBh
* @param queryType asjbh jjbh
* @return * @return
*/ */
@GetMapping(value = "/queryAsjxx/{queryType}/{queryBh}") @GetMapping(value = "/queryAsjxx")
@ResponseBody @ResponseBody
@ApiOperation(value = "审批_通过案事件编号或接警编号查询案事件信息") @ApiOperation(value = "审批_通过案事件编号或接警编号查询案事件信息")
@OperLog(czxxLbdm = "01" , yymcJyqk = "0206",czxxJyqk = "通过案事件编号或接警编号查询案事件信息") @OperLog(czxxLbdm = "01" , yymcJyqk = "0206",czxxJyqk = "通过案事件编号或接警编号查询案事件信息")
public JSONObject queryAsjxx(@PathVariable("queryBh")String queryBh, @PathVariable("queryType")String queryType){ public JSONObject queryAsjxx( String queryBh){
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
ApprovalTbStAsj asj =null; ApprovalTbStAsj asj =null;
try { try {
asj = orderDetailService.queryAsjxx(queryBh,queryType); asj = orderDetailService.queryAsjxx(queryBh);
} catch (Exception e){ } catch (Exception e){
e.printStackTrace(); e.printStackTrace();
jsonObject.put("asjxx",asj); jsonObject.put("asjxx",asj);
......
package com.founder.publicapi.controller.ApprovalService; package com.founder.publicapi.controller.ApprovalService;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.URLUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.founder.commonutils.model.newPublicEntity.ApprovalEntity.OperLog; import com.founder.commonutils.model.newPublicEntity.ApprovalEntity.OperLog;
import com.founder.commonutils.model.newPublicEntity.ApprovalEntity.TbstApprovePzxx; import com.founder.commonutils.model.newPublicEntity.ApprovalEntity.TbstApprovePzxx;
import com.founder.commonutils.model.newPublicEntity.MapRestResult; import com.founder.commonutils.model.newPublicEntity.MapRestResult;
import com.founder.commonutils.model.newPublicEntity.result.ApiException;
import com.founder.publicapi.service.PzService; import com.founder.publicapi.service.PzService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList; import javax.servlet.http.HttpServletResponse;
import java.util.HashMap; import java.io.*;
import java.util.List; import java.net.URL;
import java.util.Map; import java.net.URLEncoder;
import java.util.*;
/** /**
...@@ -28,6 +32,15 @@ public class PzGlController { ...@@ -28,6 +32,15 @@ public class PzGlController {
@Autowired @Autowired
private PzService pzService; private PzService pzService;
@Value("${approvalDownloadTemplate}")
private String APPROVAL_DOWNLOAD_TEMPLATE_PATH;//新增卷宗大数据模型下载模板的路径
@Value("${approvalDownload}")
private String APPROVAL_DOWNLOAD;//新增卷宗大数据模型下载路径
@Value("${approvalFilePath}")
private String APPROVAL_FILE_PATH;//卷宗上传的路径
/** /**
* 保存新的卷宗 * 保存新的卷宗
* @return * @return
...@@ -36,8 +49,22 @@ public class PzGlController { ...@@ -36,8 +49,22 @@ public class PzGlController {
@ResponseBody @ResponseBody
@OperLog(czxxLbdm = "01" , yymcJyqk = "0206",czxxJyqk = "审批_新增卷宗(保存)") @OperLog(czxxLbdm = "01" , yymcJyqk = "0206",czxxJyqk = "审批_新增卷宗(保存)")
@ApiOperation(value = "审批_新增卷宗(保存)") @ApiOperation(value = "审批_新增卷宗(保存)")
public JSONObject savePzxx(@RequestBody TbstApprovePzxx tbstApprovePzxx){ public JSONObject savePzxx( TbstApprovePzxx tbstApprovePzxx,@RequestParam (required = false) MultipartFile multipartFile ){
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
if (tbstApprovePzxx.getAjlb().equals("大数据建模")){
String originalName = multipartFile.getOriginalFilename().toLowerCase(Locale.ROOT);
tbstApprovePzxx.setWordName(originalName);
try {
tbstApprovePzxx.setWordFile(multipartFile.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
result = pzService.savePzxx(tbstApprovePzxx);
//上传到服务器
String username = tbstApprovePzxx.getCreateUserId();
String jzmc = (String) result.get("data");
saveInResources(multipartFile,username,jzmc);
}else
try { try {
result = pzService.savePzxx(tbstApprovePzxx); result = pzService.savePzxx(tbstApprovePzxx);
} catch (Exception e) { } catch (Exception e) {
...@@ -51,6 +78,69 @@ public class PzGlController { ...@@ -51,6 +78,69 @@ public class PzGlController {
} }
/** /**
* 上传文件到服务器
* @param file
* @param username
* @param jzmc
*/
public void saveInResources(MultipartFile file, String username,String jzmc) {
//判断文件类型
String originalName = file.getOriginalFilename().toLowerCase(Locale.ROOT);
String postfix = originalName.substring(originalName.lastIndexOf("."));
if (!originalName.endsWith(".docx") && !originalName.endsWith(".doc")) {
throw new ApiException(201, "上传失败,请选择doxc或doc文件");
}
String path = APPROVAL_FILE_PATH + username + "/" + jzmc + postfix;
try {
FileUtil.writeBytes(file.getBytes(), path);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 下载word文件
* @return
*/
@PostMapping(value = "/downloadWord")
@ResponseBody
@OperLog(czxxLbdm = "01" , yymcJyqk = "0206",czxxJyqk = "审批_下载文件")
@ApiOperation(value = "审批_下载文件")
public void downloadWord(@RequestBody TbstApprovePzxx tbstApprovePzxx,HttpServletResponse response) throws Exception {
String username = tbstApprovePzxx.getCreateUserId();
String jzmc = tbstApprovePzxx.getId();
String fileName =tbstApprovePzxx.getWordName();
String postfix = fileName.substring(fileName.lastIndexOf("."));
String prefix = fileName.substring(0,fileName.lastIndexOf("."));
try {
//下载的路径
String path1 = APPROVAL_DOWNLOAD + username + "/" + jzmc + postfix;
String path = URLUtil.encode(path1);
// 以流的形式下载文件。
InputStream fis = URLUtil.getStream(new URL(path));
byte[] buffer = new byte[fis.available()];
fis.read(buffer);
fis.close();
//清空response
response.reset();
//设置response响应头
response.setCharacterEncoding("UTF-8");
response.setContentType("multipart/form-data");
response.setContentType("application/x-download");
response.setHeader("Accept-Ranges", "bytes");
response.setHeader("content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "utf-8"));
OutputStream outputStream = new BufferedOutputStream(response.getOutputStream());
response.setContentType("application/octet-stream");
outputStream.write(buffer);
outputStream.flush();
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 删除指定卷宗 * 删除指定卷宗
* @return * @return
*/ */
...@@ -147,4 +237,43 @@ public class PzGlController { ...@@ -147,4 +237,43 @@ public class PzGlController {
mapResult.put("count",result.size()); mapResult.put("count",result.size());
return mapResult; return mapResult;
} }
/**
* 下载模板
* @return
*/
@GetMapping(value = "/downloadTemplate")
@ResponseBody
@OperLog(czxxLbdm = "01" , yymcJyqk = "0206",czxxJyqk = "审批_下载模板")
@ApiOperation(value = "审批_下载模板")
public void downloadTemplate(HttpServletResponse response) throws Exception {
try {
//下载的路径
String path = URLUtil.encode(APPROVAL_DOWNLOAD_TEMPLATE_PATH);
// 以流的形式下载文件。
InputStream fis = URLUtil.getStream(new URL(path));
byte[] buffer = new byte[fis.available()];
fis.read(buffer);
fis.close();
//清空response
response.reset();
//设置response响应头
response.setCharacterEncoding("UTF-8");
response.setContentType("multipart/form-data");
response.setContentType("application/x-download");
response.setHeader("Accept-Ranges", "bytes");
response.setHeader("content-Disposition", "attachment;filename=" + URLEncoder.encode("上传文件模板.docx", "utf-8"));
OutputStream outputStream = new BufferedOutputStream(response.getOutputStream());
response.setContentType("application/octet-stream");
outputStream.write(buffer);
outputStream.flush();
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
...@@ -20,7 +20,9 @@ ...@@ -20,7 +20,9 @@
JSSJ, JSSJ,
YXQX, YXQX,
<if test="imgFile != null and imgFile != ''">IMG_FILE,</if> <if test="imgFile != null and imgFile != ''">IMG_FILE,</if>
CREATE_TIME CREATE_TIME,
<if test="wordFile != null and wordFile != ''">WORDFILE,</if>
WORD_NAME
) values ( ) values (
#{id} #{id}
<if test="asjbh != null and asjbh != ''">,#{asjbh}</if> <if test="asjbh != null and asjbh != ''">,#{asjbh}</if>
...@@ -53,6 +55,9 @@ ...@@ -53,6 +55,9 @@
<if test="yxqx == null or yxqx == ''">,NULL</if> <if test="yxqx == null or yxqx == ''">,NULL</if>
<if test="imgFile != null and imgFile != ''">,#{imgFile}</if> <if test="imgFile != null and imgFile != ''">,#{imgFile}</if>
,NOW() ,NOW()
<if test="wordFile != null and wordFile != ''">,#{wordFile}</if>
<if test="wordName != null and wordName != ''">,#{wordName}</if>
<if test="wordName == null or wordName == ''">,NULL</if>
) )
</insert> </insert>
<delete id="deletePzById" parameterType="com.founder.commonutils.model.newPublicEntity.ApprovalEntity.TbstApprovePzxx"> <delete id="deletePzById" parameterType="com.founder.commonutils.model.newPublicEntity.ApprovalEntity.TbstApprovePzxx">
...@@ -140,6 +145,7 @@ ...@@ -140,6 +145,7 @@
a.CREATE_USER_ID as createUserId, a.CREATE_USER_ID as createUserId,
a.LRLB as lrlb, a.LRLB as lrlb,
a.IMG_FILE as imgFile, a.IMG_FILE as imgFile,
a.WORD_NAME as wordName,
(select count(*) from sk_st_approve_order where PZID=a.ID) as yxqx, (select count(*) from sk_st_approve_order where PZID=a.ID) as yxqx,
date_format(a.KSSJ,'%Y-%m-%d %H:%i:%s') as kssj, date_format(a.KSSJ,'%Y-%m-%d %H:%i:%s') as kssj,
date_format(a.JSSJ,'%Y-%m-%d %H:%i:%s') as jssj, date_format(a.JSSJ,'%Y-%m-%d %H:%i:%s') as jssj,
......
...@@ -32,6 +32,6 @@ public interface OrderDetailService { ...@@ -32,6 +32,6 @@ public interface OrderDetailService {
JSONObject getFsrwqx(String username, String queryType, String xsz); JSONObject getFsrwqx(String username, String queryType, String xsz);
ApprovalTbStAsj queryAsjxx(String queryBh, String queryType); ApprovalTbStAsj queryAsjxx(String queryBh);
} }
...@@ -417,7 +417,7 @@ public class OrderDetailServiceImpl implements OrderDetailService { ...@@ -417,7 +417,7 @@ public class OrderDetailServiceImpl implements OrderDetailService {
return date.after(begin) && date.before(end); return date.after(begin) && date.before(end);
} }
@Override @Override
public ApprovalTbStAsj queryAsjxx(String queryBh, String queryType) { public ApprovalTbStAsj queryAsjxx(String queryBh) {
ApprovalTbStAsj tbStAsj = new ApprovalTbStAsj(); ApprovalTbStAsj tbStAsj = new ApprovalTbStAsj();
tbStAsj.setAsjbh(queryBh); tbStAsj.setAsjbh(queryBh);
return tbStAsjMapper.queryAsjxx(tbStAsj); return tbStAsjMapper.queryAsjxx(tbStAsj);
......
...@@ -22,7 +22,8 @@ public class PzServiceImpl implements PzService { ...@@ -22,7 +22,8 @@ public class PzServiceImpl implements PzService {
@Override @Override
public JSONObject savePzxx(TbstApprovePzxx tbstApprovePzxx) { public JSONObject savePzxx(TbstApprovePzxx tbstApprovePzxx) {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
tbstApprovePzxx.setId(KeyUtilNaotu.getJzKey("JZ")); String jzid = KeyUtilNaotu.getJzKey("JZ");
tbstApprovePzxx.setId(jzid);
String yxqx = tbstApprovePzxx.getYxqx(); String yxqx = tbstApprovePzxx.getYxqx();
tbstApprovePzxx.setKssj(getYxSj(yxqx,"kssj")); tbstApprovePzxx.setKssj(getYxSj(yxqx,"kssj"));
tbstApprovePzxx.setJssj(getYxSj(yxqx,"jssj")); tbstApprovePzxx.setJssj(getYxSj(yxqx,"jssj"));
...@@ -31,7 +32,7 @@ public class PzServiceImpl implements PzService { ...@@ -31,7 +32,7 @@ public class PzServiceImpl implements PzService {
jsonObject.put("status",200); jsonObject.put("status",200);
jsonObject.put("count",0); jsonObject.put("count",0);
jsonObject.put("msg","卷宗保存成功"); jsonObject.put("msg","卷宗保存成功");
jsonObject.put("data",""); jsonObject.put("data",jzid);
}else{ }else{
jsonObject.put("status",201); jsonObject.put("status",201);
jsonObject.put("count",0); jsonObject.put("count",0);
......
...@@ -134,32 +134,7 @@ public class UserServiceImpl implements UserService { ...@@ -134,32 +134,7 @@ public class UserServiceImpl implements UserService {
roleId.add(YJSP_ROLEID);//只有具有一级审批权限的才能代理二级审批权限 roleId.add(YJSP_ROLEID);//只有具有一级审批权限的才能代理二级审批权限
allUsers = userMapper.getUserWithRoles(param,roleId,null); allUsers = userMapper.getUserWithRoles(param,roleId,null);
return allUsers; return allUsers;
/*List<User> allUsers= new ArrayList<>();
User loginUser = new User();
loginUser.setPolicemanid(loginUserPoliceId);
try {
loginUser = userMapper.getSysUser(loginUser).get(0);
} catch (Exception e) {
e.printStackTrace();
}
String unitCode=loginUser.getUnitcode().substring(0,6);
User param=new User();
param.setUnitcode(unitCode);
if(!StringUtils.isEmpty(agentUserPoliceId)){
param.setPolicemanid(agentUserPoliceId);
}
if(!StringUtils.isEmpty(agentUserXm)){
param.setTrueName(agentUserXm);
}
List<String> roleId=new ArrayList<>();
roleId.add(YJSP_ROLEID);//二级权限下发给一级
List<User> allUser = userMapper.getUserWithRoles(param,roleId,null);
for(User user:allUser){//过滤掉自己
if(!loginUserPoliceId.equals(user.getPolicemanid())){
allUsers.add(user);
}
}
return allUsers;*/
} }
@Override @Override
......
...@@ -34,6 +34,13 @@ hnkshDownloadFilePath = http://47.92.48.137:1009/excel/kshExcel/ ...@@ -34,6 +34,13 @@ hnkshDownloadFilePath = http://47.92.48.137:1009/excel/kshExcel/
#\u6570\u636E\u5206\u6790\u4E0B\u8F7D\u6A21\u677F\u7684\u8DEF\u5F84 #\u6570\u636E\u5206\u6790\u4E0B\u8F7D\u6A21\u677F\u7684\u8DEF\u5F84
hnkshDownloadExcelTemplatePath = http://47.92.48.137:1009/excel/kshExcel/ExcelTemplate.xls hnkshDownloadExcelTemplatePath = http://47.92.48.137:1009/excel/kshExcel/ExcelTemplate.xls
#\u5377\u5B97\u4E0A\u4F20\u7684\u8DEF\u5F84
approvalFilePath = /data/excel/approvalWord/
#\u65B0\u589E\u5377\u5B97\u5927\u6570\u636E\u6A21\u578B\u4E0B\u8F7D\u8DEF\u5F84
approvalDownload = http://47.92.48.137:1009/excel/approvalWord/
#\u65B0\u589E\u5377\u5B97\u5927\u6570\u636E\u6A21\u578B\u4E0B\u8F7D\u6A21\u677F\u7684\u8DEF\u5F84
approvalDownloadTemplate = http://47.92.48.137:1009/excel/approvalWord/ApprovalWordTemplate.docx
#xml??? #xml???
mybatis-plus.mapper-locations=classpath*:com/founder/publicapi/mapper/*/xml/*.xml mybatis-plus.mapper-locations=classpath*:com/founder/publicapi/mapper/*/xml/*.xml
#es????????? #es?????????
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment