|
@@ -3,22 +3,32 @@
|
|
*/
|
|
*/
|
|
package com.jeeplus.modules.sg.information.web;
|
|
package com.jeeplus.modules.sg.information.web;
|
|
|
|
|
|
|
|
+import java.io.*;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import javax.servlet.http.HttpSession;
|
|
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
|
+import com.jeeplus.common.utils.DateUtils;
|
|
import com.jeeplus.common.utils.excel.ExportExcel;
|
|
import com.jeeplus.common.utils.excel.ExportExcel;
|
|
import com.jeeplus.modules.sg.information.entity.Information;
|
|
import com.jeeplus.modules.sg.information.entity.Information;
|
|
|
|
+import com.jeeplus.modules.sg.information.entity.InformationDto;
|
|
|
|
+import com.jeeplus.modules.sg.information.entity.append;
|
|
import com.jeeplus.modules.sg.information.service.InformationService;
|
|
import com.jeeplus.modules.sg.information.service.InformationService;
|
|
import com.jeeplus.modules.sg.information.utils.ImportInformation;
|
|
import com.jeeplus.modules.sg.information.utils.ImportInformation;
|
|
|
|
+import com.jeeplus.modules.sg.material.entity.Material;
|
|
import com.jeeplus.modules.sg.material.service.MaterialService;
|
|
import com.jeeplus.modules.sg.material.service.MaterialService;
|
|
import io.swagger.models.auth.In;
|
|
import io.swagger.models.auth.In;
|
|
|
|
+import net.sf.ehcache.util.concurrent.ConcurrentHashMap;
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
|
+import org.apache.shiro.session.Session;
|
|
import org.h2.util.New;
|
|
import org.h2.util.New;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.security.access.method.P;
|
|
import org.springframework.security.access.method.P;
|
|
@@ -79,6 +89,8 @@ public class InformationController extends BaseController {
|
|
//@RequiresPermissions("test:onetomany:dialog:testDataMain1:list")
|
|
//@RequiresPermissions("test:onetomany:dialog:testDataMain1:list")
|
|
@RequestMapping(value = "data")
|
|
@RequestMapping(value = "data")
|
|
public Map<String, Object> data(Information information, HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
public Map<String, Object> data(Information information, HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
|
+ HttpSession session = request.getSession();
|
|
|
|
+ session.removeAttribute("path");
|
|
Page<Information> page = informationService.findPage(new Page<Information>(request, response), information);
|
|
Page<Information> page = informationService.findPage(new Page<Information>(request, response), information);
|
|
return getBootstrapData(page);
|
|
return getBootstrapData(page);
|
|
}
|
|
}
|
|
@@ -94,7 +106,7 @@ public class InformationController extends BaseController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 导入欠供物资Excel数据
|
|
|
|
|
|
+ * 导入甲供物资Excel数据
|
|
*/
|
|
*/
|
|
//@RequiresPermissions("test:onetomany:dialog:information:import")
|
|
//@RequiresPermissions("test:onetomany:dialog:information:import")
|
|
@ResponseBody
|
|
@ResponseBody
|
|
@@ -111,19 +123,19 @@ public class InformationController extends BaseController {
|
|
Map<String, Object> information = ImportInformation.importmation(ei, lastDataRowNum);
|
|
Map<String, Object> information = ImportInformation.importmation(ei, lastDataRowNum);
|
|
int failureNum = Integer.parseInt(information.get("failureNum").toString());
|
|
int failureNum = Integer.parseInt(information.get("failureNum").toString());
|
|
int successNum = Integer.parseInt(information.get("successNum").toString());
|
|
int successNum = Integer.parseInt(information.get("successNum").toString());
|
|
- List<Information> informationList= (List<Information>)information.get("importmation");
|
|
|
|
|
|
+ List<Material> informationList= (List<Material>)information.get("errorMaterial");
|
|
if (failureNum>0){
|
|
if (failureNum>0){
|
|
failureMsg.insert(0, ",失败 "+failureNum+" 项目管理记录。");
|
|
failureMsg.insert(0, ",失败 "+failureNum+" 项目管理记录。");
|
|
}
|
|
}
|
|
if (informationList != null) {
|
|
if (informationList != null) {
|
|
if (informationList.size() >0) {
|
|
if (informationList.size() >0) {
|
|
- for (Information in :informationList) {
|
|
|
|
- failInformation.append(in.getProjectName()+";");
|
|
|
|
|
|
+ for (Material in :informationList) {
|
|
|
|
+ failInformation.append(in.getMaterialName()+";");
|
|
}
|
|
}
|
|
failInformation.append("以上物料因出库数量与数据库中不一致未能插入");
|
|
failInformation.append("以上物料因出库数量与数据库中不一致未能插入");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- j.setMsg( "已成功导入 "+successNum+" 项目管理记录"+failureMsg+failInformation);
|
|
|
|
|
|
+ j.setMsg( "已成功导入 "+successNum+" 项目管理记录;"+failureMsg+failInformation);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
j.setSuccess(false);
|
|
j.setSuccess(false);
|
|
j.setMsg("导入项目管理信息失败!失败信息:"+e.getMessage());
|
|
j.setMsg("导入项目管理信息失败!失败信息:"+e.getMessage());
|
|
@@ -156,22 +168,27 @@ public class InformationController extends BaseController {
|
|
return j;
|
|
return j;
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 批量导入模板
|
|
|
|
- * */
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
@ResponseBody
|
|
@ResponseBody
|
|
-// @RequiresPermissions("test:onetomany:form:testDataMain2:import")
|
|
|
|
- @RequestMapping(value = "import/template")
|
|
|
|
- public AjaxJson importFileTemplate(HttpServletResponse response) {
|
|
|
|
|
|
+ @RequestMapping(value = "importInTrial")
|
|
|
|
+ public AjaxJson importInTrial(@RequestParam("file")MultipartFile file, HttpServletResponse response, HttpServletRequest request) {
|
|
AjaxJson j = new AjaxJson();
|
|
AjaxJson j = new AjaxJson();
|
|
try {
|
|
try {
|
|
- String fileName = "批量项目查询导入模板.xlsx";
|
|
|
|
- List<Information> list = Lists.newArrayList();
|
|
|
|
- new ExportExcel("", Information.class, 1).setDataList(list).write(response, fileName).dispose();
|
|
|
|
- return null;
|
|
|
|
|
|
+ StringBuilder failureMsg = new StringBuilder();
|
|
|
|
+ ImportExcel ei = new ImportExcel(file, 1, 0);
|
|
|
|
+ int lastDataRowNum = ei.getLastDataRowNum();
|
|
|
|
+ Map<String, Integer> importInTrial = ImportInformation.importInTrial(ei, lastDataRowNum);
|
|
|
|
+ int failureNum = importInTrial.get("failureNum");
|
|
|
|
+ int successNum = importInTrial.get("successNum");
|
|
|
|
+ if (failureNum>0){
|
|
|
|
+ failureMsg.insert(0, ",失败 "+failureNum+" 项目管理记录。");
|
|
|
|
+ }
|
|
|
|
+ j.setMsg( "已成功导入 "+successNum+" 条记录"+failureMsg);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
j.setSuccess(false);
|
|
j.setSuccess(false);
|
|
- j.setMsg( "批量项目查询下载失败!失败信息:"+e.getMessage());
|
|
|
|
|
|
+ j.setMsg("导入项审定日期失败!失败信息:"+e.getMessage());
|
|
}
|
|
}
|
|
return j;
|
|
return j;
|
|
}
|
|
}
|
|
@@ -183,6 +200,7 @@ public class InformationController extends BaseController {
|
|
AjaxJson j = new AjaxJson();
|
|
AjaxJson j = new AjaxJson();
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
ImportExcel ei = null;
|
|
ImportExcel ei = null;
|
|
|
|
+ String canonicalPath = "";
|
|
try {
|
|
try {
|
|
ei = new ImportExcel(file, 1, 0);
|
|
ei = new ImportExcel(file, 1, 0);
|
|
}catch (Exception e) {
|
|
}catch (Exception e) {
|
|
@@ -201,14 +219,246 @@ public class InformationController extends BaseController {
|
|
infor.add(information1);
|
|
infor.add(information1);
|
|
}
|
|
}
|
|
List<Information> listBy = informationService.findListBy(infor);
|
|
List<Information> listBy = informationService.findListBy(infor);
|
|
|
|
+ try {
|
|
|
|
+ File temp =new File("C:\\Users\\lem\\AppData\\Local\\Temp\\information");
|
|
|
|
+ /**
|
|
|
|
+ * 在临时文件中写入内容
|
|
|
|
+ */
|
|
|
|
+ BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(temp));
|
|
|
|
+ for (Information items :
|
|
|
|
+ listBy) {
|
|
|
|
+ String a = items.getProjectId();
|
|
|
|
+ bufferedWriter.write(a+"\r");
|
|
|
|
+ }
|
|
|
|
+ bufferedWriter.close();
|
|
|
|
+
|
|
|
|
+/* *//**
|
|
|
|
+ * 读取临时文件中的内容
|
|
|
|
+ *//*
|
|
|
|
+ BufferedReader bufferedReader = new BufferedReader(new FileReader(temp));
|
|
|
|
+ String string;
|
|
|
|
+ List list1 = new ArrayList();
|
|
|
|
+ while ((string=bufferedReader.readLine()) != null){
|
|
|
|
+ System.out.println(string);
|
|
|
|
+ list1.add(string);
|
|
|
|
+ }
|
|
|
|
+ bufferedReader.close();*/
|
|
|
|
+ canonicalPath = temp.getCanonicalPath();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
String listCount = String.valueOf(listBy.size());
|
|
String listCount = String.valueOf(listBy.size());
|
|
long l = Long.parseLong(listCount);
|
|
long l = Long.parseLong(listCount);
|
|
Page<Information> page = new Page(1, listBy.size(), l, listBy);
|
|
Page<Information> page = new Page(1, listBy.size(), l, listBy);
|
|
- List<Information> list = page.getList();
|
|
|
|
- long count = page.getCount();
|
|
|
|
|
|
+ HttpSession session = request.getSession();
|
|
|
|
+ session.setAttribute("path",canonicalPath);
|
|
return getBootstrapData(page);
|
|
return getBootstrapData(page);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 批量导入模板
|
|
|
|
+ * */
|
|
|
|
+ @ResponseBody
|
|
|
|
+// @RequiresPermissions("test:onetomany:form:testDataMain2:import")
|
|
|
|
+ @RequestMapping(value = "import/template")
|
|
|
|
+ public AjaxJson importFileTemplate(HttpServletResponse response) {
|
|
|
|
+ AjaxJson j = new AjaxJson();
|
|
|
|
+ try {
|
|
|
|
+ String fileName = "批量项目查询导入模板.xlsx";
|
|
|
|
+ List<Information> list = Lists.newArrayList();
|
|
|
|
+ new ExportExcel("", InformationDto.class, 1).setDataList(list).write(response, fileName).dispose();
|
|
|
|
+ return null;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ j.setSuccess(false);
|
|
|
|
+ j.setMsg( "批量项目查询下载失败!失败信息:"+e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ return j;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @ResponseBody
|
|
|
|
+// @RequiresPermissions("test:onetomany:form:testDataMain2:import")
|
|
|
|
+ @RequestMapping(value = "import/templates")
|
|
|
|
+ public AjaxJson importFileTemplateS(HttpServletResponse response) {
|
|
|
|
+ AjaxJson j = new AjaxJson();
|
|
|
|
+ try {
|
|
|
|
+ String fileName = "导入送审.xlsx";
|
|
|
|
+ List<append> list = Lists.newArrayList();
|
|
|
|
+ new ExportExcel("", append.class, 1).setDataList(list).write(response, fileName).dispose();
|
|
|
|
+ return null;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ j.setSuccess(false);
|
|
|
|
+ j.setMsg( "导入送审下载失败!失败信息:"+e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ return j;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public static Map<String, ExportExcel> excelParamCache = new ConcurrentHashMap<>();
|
|
|
|
+ @ResponseBody
|
|
|
|
+ //@RequiresPermissions("test:onetomany:dialog:testDataMain1:export")
|
|
|
|
+ @RequestMapping(value = "exportMaterial")
|
|
|
|
+ public AjaxJson exportMaterial(Information information,HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
+ String projectId = "";
|
|
|
|
+ String projectName = "";
|
|
|
|
+ String projectType = "";
|
|
|
|
+ String projectYear = "";
|
|
|
|
+ String firstUnits = "";
|
|
|
|
+ String secondUnits = "";
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ projectId = request.getParameter("projectId");
|
|
|
|
+ projectName = request.getParameter("projectName");
|
|
|
|
+ projectName = new String(projectName.getBytes("iso8859-1"),"utf-8");
|
|
|
|
+ projectType = request.getParameter("projectType");
|
|
|
|
+ projectType = new String(projectType.getBytes("iso8859-1"),"utf-8");
|
|
|
|
+ projectYear = request.getParameter("projectYear");
|
|
|
|
+ projectYear = new String(projectYear.getBytes("iso8859-1"),"utf-8");
|
|
|
|
+ firstUnits= request.getParameter("firstUnits");
|
|
|
|
+ firstUnits = new String(firstUnits.getBytes("iso8859-1"),"utf-8");
|
|
|
|
+ secondUnits= request.getParameter("secondUnits");
|
|
|
|
+ secondUnits = new String(secondUnits.getBytes("iso8859-1"),"utf-8");
|
|
|
|
+
|
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ HttpSession session = request.getSession();
|
|
|
|
+ Object path = session.getAttribute("path");
|
|
|
|
+ List<Information> tList = new ArrayList<>();
|
|
|
|
+ AjaxJson j = new AjaxJson();
|
|
|
|
+ if (path != null && path != "") {
|
|
|
|
+// * 读取临时文件中的内容
|
|
|
|
+ BufferedReader bufferedReader = null;
|
|
|
|
+ try {
|
|
|
|
+ bufferedReader = new BufferedReader(new FileReader(path.toString()));
|
|
|
|
+ String string;
|
|
|
|
+ while ((string=bufferedReader.readLine()) != null){
|
|
|
|
+ Information information1 = new Information();
|
|
|
|
+ information1.setProjectId(string);
|
|
|
|
+ tList.add(information1);
|
|
|
|
+ }
|
|
|
|
+ bufferedReader.close();
|
|
|
|
+ try {
|
|
|
|
+ String fileName = "导出物料清单"+ DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
|
|
|
|
+ List<Material> materialList = informationService.allNoBack(tList);
|
|
|
|
+ new ExportExcel("导出物料清单", Material.class).setDataList(materialList).write(response, fileName).dispose();
|
|
|
|
+ j.setSuccess(true);
|
|
|
|
+ j.setMsg("导出成功!");
|
|
|
|
+ return j;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ j.setSuccess(false);
|
|
|
|
+ j.setMsg("导出物料清单!失败信息:"+e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ Information information1 = new Information();
|
|
|
|
+ information1.setProjectId(projectId);
|
|
|
|
+ information1.setProjectName(projectName);
|
|
|
|
+ information1.setProjectType(projectType);
|
|
|
|
+ information1.setProjectYear(projectYear);
|
|
|
|
+ information1.setFirstUnits(firstUnits);
|
|
|
|
+ information1.setSecondUnits(secondUnits);
|
|
|
|
+ tList.add(information1);
|
|
|
|
+ try {
|
|
|
|
+ String fileName = "导出物料清单"+ DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
|
|
|
|
+ List<Material> materialList = informationService.allNo(tList);
|
|
|
|
+ new ExportExcel("导出物料清单", Material.class).setDataList(materialList).write(response, fileName).dispose();
|
|
|
|
+ j.setSuccess(true);
|
|
|
|
+ j.setMsg("导出成功!");
|
|
|
|
+ return j;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ j.setSuccess(false);
|
|
|
|
+ j.setMsg("导出物料清单!失败信息:"+e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return j;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @ResponseBody
|
|
|
|
+ //@RequiresPermissions("test:onetomany:dialog:testDataMain1:export")
|
|
|
|
+ @RequestMapping(value = "export")
|
|
|
|
+ public AjaxJson export(Information information,HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
+ String projectId = "";
|
|
|
|
+ String projectName = "";
|
|
|
|
+ String projectType = "";
|
|
|
|
+ String projectYear = "";
|
|
|
|
+ String firstUnits = "";
|
|
|
|
+ String secondUnits = "";
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ projectId = request.getParameter("projectId");
|
|
|
|
+ projectName = request.getParameter("projectName");
|
|
|
|
+ projectName = new String(projectName.getBytes("iso8859-1"),"utf-8");
|
|
|
|
+ projectType = request.getParameter("projectType");
|
|
|
|
+ projectType = new String(projectType.getBytes("iso8859-1"),"utf-8");
|
|
|
|
+ projectYear = request.getParameter("projectYear");
|
|
|
|
+ projectYear = new String(projectYear.getBytes("iso8859-1"),"utf-8");
|
|
|
|
+ firstUnits= request.getParameter("firstUnits");
|
|
|
|
+ firstUnits = new String(firstUnits.getBytes("iso8859-1"),"utf-8");
|
|
|
|
+ secondUnits= request.getParameter("secondUnits");
|
|
|
|
+ secondUnits = new String(secondUnits.getBytes("iso8859-1"),"utf-8");
|
|
|
|
+
|
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ HttpSession session = request.getSession();
|
|
|
|
+ Object path = session.getAttribute("path");
|
|
|
|
+ List<Information> tList = new ArrayList<>();
|
|
|
|
+ AjaxJson j = new AjaxJson();
|
|
|
|
+ if (path != null && path != "") {
|
|
|
|
+// * 读取临时文件中的内容
|
|
|
|
+ BufferedReader bufferedReader = null;
|
|
|
|
+ try {
|
|
|
|
+ bufferedReader = new BufferedReader(new FileReader(path.toString()));
|
|
|
|
+ String string;
|
|
|
|
+ while ((string=bufferedReader.readLine()) != null){
|
|
|
|
+ Information information1 = new Information();
|
|
|
|
+ information1.setProjectId(string);
|
|
|
|
+ tList.add(information1);
|
|
|
|
+ }
|
|
|
|
+ bufferedReader.close();
|
|
|
|
+ try {
|
|
|
|
+ String fileName = "导出项目清单"+ DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
|
|
|
|
+ List<Information> informationList = informationService.exportInfor(tList);
|
|
|
|
+ new ExportExcel("导出项目清单", Information.class).setDataList(informationList).write(response, fileName).dispose();
|
|
|
|
+ j.setSuccess(true);
|
|
|
|
+ j.setMsg("导出成功!");
|
|
|
|
+ return j;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ j.setSuccess(false);
|
|
|
|
+ j.setMsg("导出项目清单!失败信息:"+e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ Information information1 = new Information();
|
|
|
|
+ information1.setProjectId(projectId);
|
|
|
|
+ information1.setProjectName(projectName);
|
|
|
|
+ information1.setProjectType(projectType);
|
|
|
|
+ information1.setProjectYear(projectYear);
|
|
|
|
+ information1.setFirstUnits(firstUnits);
|
|
|
|
+ information1.setSecondUnits(secondUnits);
|
|
|
|
+ tList.add(information1);
|
|
|
|
+ try {
|
|
|
|
+ String fileName = "导出项目清单"+ DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
|
|
|
|
+ List<Information> informationList = informationService.export(tList);
|
|
|
|
+ new ExportExcel("导出项目清单", Information.class).setDataList(informationList).write(response, fileName).dispose();
|
|
|
|
+ j.setSuccess(true);
|
|
|
|
+ j.setMsg("导出成功!");
|
|
|
|
+ return j;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ j.setSuccess(false);
|
|
|
|
+ j.setMsg("导出项目清单!失败信息:"+e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return j;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|