|
@@ -11,17 +11,16 @@ import com.jeeplus.common.config.Global;
|
|
|
import com.jeeplus.common.mapper.JsonMapper;
|
|
|
import com.jeeplus.common.oss.OSSClientUtil;
|
|
|
import com.jeeplus.common.persistence.Page;
|
|
|
-import com.jeeplus.common.utils.DateUtils;
|
|
|
-import com.jeeplus.common.utils.IdGen;
|
|
|
-import com.jeeplus.common.utils.MyBeanUtils;
|
|
|
-import com.jeeplus.common.utils.StringUtils;
|
|
|
+import com.jeeplus.common.utils.*;
|
|
|
import com.jeeplus.common.utils.excel.ExportExcel;
|
|
|
import com.jeeplus.common.utils.excel.ImportExcel;
|
|
|
import com.jeeplus.common.web.BaseController;
|
|
|
+import com.jeeplus.modules.projectcontentinfo.entity.ProjectReportData;
|
|
|
import com.jeeplus.modules.sys.entity.Role;
|
|
|
import com.jeeplus.modules.sys.service.SystemService;
|
|
|
import com.jeeplus.modules.sys.utils.DictUtils;
|
|
|
import com.jeeplus.modules.sys.utils.UserUtils;
|
|
|
+import com.jeeplus.modules.tools.utils.TwoDimensionCode;
|
|
|
import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
|
|
|
import com.jeeplus.modules.workclientinfo.entity.WorkClientInfo;
|
|
|
import com.jeeplus.modules.workclientinfo.entity.WorkClientLinkman;
|
|
@@ -37,10 +36,12 @@ import com.jeeplus.modules.workproject.entity.WorkProject;
|
|
|
import com.jeeplus.modules.workproject.service.WorkProjectService;
|
|
|
import com.jeeplus.modules.workprojectnotify.service.WorkProjectNotifyService;
|
|
|
import com.jeeplus.modules.workprojectnotify.util.UtilNotify;
|
|
|
+import freemarker.template.Configuration;
|
|
|
import org.apache.commons.lang.ArrayUtils;
|
|
|
import org.apache.shiro.authz.annotation.Logical;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.Model;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -50,6 +51,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.servlet.http.HttpSession;
|
|
|
import javax.validation.ConstraintViolationException;
|
|
|
import java.io.*;
|
|
|
import java.net.HttpURLConnection;
|
|
@@ -57,6 +59,7 @@ import java.net.URL;
|
|
|
import java.net.URLDecoder;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.*;
|
|
|
+import freemarker.template.Template;
|
|
|
|
|
|
/**
|
|
|
* 全过程管理Controller
|
|
@@ -94,6 +97,12 @@ public class WorkFullManageController extends BaseController {
|
|
|
@Autowired
|
|
|
private WorkFullSurveyService workFullSurveyService;
|
|
|
|
|
|
+ //生产环境域名
|
|
|
+ @Value("${serverDomain}")
|
|
|
+ private String serverDomain;
|
|
|
+
|
|
|
+ private static final String FILE_NAME = "防伪报告模板.doc";
|
|
|
+
|
|
|
@ModelAttribute
|
|
|
public WorkFullManage get(@RequestParam(required=false) String id) {
|
|
|
WorkFullManage entity = null;
|
|
@@ -742,4 +751,74 @@ public class WorkFullManageController extends BaseController {
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ @RequestMapping(value="downloadDoc")
|
|
|
+ @ResponseBody
|
|
|
+ public void downloadDoc(HttpServletResponse response, ProjectReportData projectReportData) {
|
|
|
+ String number = projectReportData.getNumber();
|
|
|
+ String[] numFront=number.split("【");
|
|
|
+ List list = new ArrayList();
|
|
|
+ for (int i = 0; i<numFront.length;i++){
|
|
|
+ if(!numFront[i].contains("】")){
|
|
|
+ list.add(numFront[i]);
|
|
|
+ }else{
|
|
|
+ String[] numLater=numFront[i].split("】");
|
|
|
+ if(numLater.length>0){
|
|
|
+ for (int j = 0; j<numLater.length;j++){
|
|
|
+ list.add(numLater[j]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String reportNo = projectReportData.getNumber();
|
|
|
+ try {
|
|
|
+ reportNo = URLEncoder.encode(URLEncoder.encode(reportNo,"utf-8"),"utf-8");
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ String querySite = serverDomain+"/ruralProject/ruralProjectRecords/getDownloadProjectView?id="+projectReportData.getProject().getId();
|
|
|
+ //模板对象
|
|
|
+ Template template=null;
|
|
|
+ //freemaker模板路径
|
|
|
+ File path = new File(this.getClass().getResource("/").getPath()+"/freemarker");
|
|
|
+ Configuration cfg = new Configuration();
|
|
|
+ try {
|
|
|
+ cfg.setDirectoryForTemplateLoading(path);
|
|
|
+// 前台传入的tempType即是对应ftl模板的文件名
|
|
|
+ template = cfg.getTemplate(projectReportData.getTempType()+".ftl","UTF-8");
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ //freemarker参数值准备
|
|
|
+ Map<String,Object> data = new HashMap<>();
|
|
|
+ data.put("repType",list.get(0));
|
|
|
+ data.put("repYear",list.get(1));
|
|
|
+ data.put("repNum",list.get(2));
|
|
|
+ data.put("querySite","re.xgccpm.com/ccpm_query");
|
|
|
+
|
|
|
+ //生成二维码图片和doc文档 缓存文件的共用名称
|
|
|
+ String commonFileName = UUID.randomUUID().toString();
|
|
|
+ String tempPath = this.getClass().getResource("/").getPath()+"/temp/";
|
|
|
+ File temP = new File(tempPath);
|
|
|
+ if(!temP.exists()){
|
|
|
+ temP.mkdirs();
|
|
|
+ }
|
|
|
+ String qrCodePath = tempPath + commonFileName + ".png";
|
|
|
+ TwoDimensionCode.encoderQRCode(querySite, qrCodePath, "png");//执行生成二维码
|
|
|
+ String imageStr = ImageUtil.getImageStr(qrCodePath);
|
|
|
+ data.put("qrcode",imageStr);
|
|
|
+ String pa = this.getClass().getResource("/").getPath();
|
|
|
+
|
|
|
+ File docFile = new File(tempPath+commonFileName+".doc");
|
|
|
+ FreemarkerUtil.generateFile(data,template,docFile);
|
|
|
+
|
|
|
+ ResponseUtil.docResponse(FILE_NAME,docFile,response);
|
|
|
+
|
|
|
+ if(docFile != null) docFile.delete(); // 删除doc临时文件
|
|
|
+ File imageFile = new File(qrCodePath);
|
|
|
+ if(imageFile.exists() && imageFile.isFile()) {
|
|
|
+ imageFile.delete();//删除二维码图片临时文件
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|