|
@@ -26,9 +26,12 @@ import com.jeeplus.modules.sg.information.entity.constant;
|
|
|
import com.jeeplus.modules.sg.information.service.InformationService;
|
|
|
import com.jeeplus.modules.sg.information.utils.FreemarkerUtil;
|
|
|
import com.jeeplus.modules.sg.information.utils.ImportInformation;
|
|
|
+import com.jeeplus.modules.sg.information.utils.RandomUtil;
|
|
|
import com.jeeplus.modules.sg.information.utils.ResponseUtil;
|
|
|
import com.jeeplus.modules.sg.material.entity.Material;
|
|
|
import com.jeeplus.modules.sg.material.service.MaterialService;
|
|
|
+import com.jeeplus.modules.sg.record.entity.Record;
|
|
|
+import com.jeeplus.modules.sg.record.service.RecordService;
|
|
|
import freemarker.template.Configuration;
|
|
|
import freemarker.template.Template;
|
|
|
import io.swagger.models.auth.In;
|
|
@@ -70,6 +73,8 @@ public class InformationController extends BaseController {
|
|
|
private InformationService informationService;
|
|
|
@Autowired
|
|
|
private MaterialService materialService;
|
|
|
+ @Autowired
|
|
|
+ private RecordService recordService;
|
|
|
|
|
|
@ModelAttribute
|
|
|
public Information get(@RequestParam(required=false) String id) {
|
|
@@ -100,8 +105,41 @@ public class InformationController extends BaseController {
|
|
|
@RequiresPermissions("modules:sg:information:information:list")
|
|
|
@RequestMapping(value = "data")
|
|
|
public Map<String, Object> data(Information information, HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
+ String hiddenSign = information.getHiddenSign();
|
|
|
HttpSession session = request.getSession();
|
|
|
- session.removeAttribute("path");
|
|
|
+ Object path = session.getAttribute("path");
|
|
|
+ if (hiddenSign.equals("不是第一次加载")) {
|
|
|
+ List<Information> tList = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ BufferedReader bufferedReader = null;
|
|
|
+ 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();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ information.setFileList(tList);
|
|
|
+ } else {
|
|
|
+ if (path != null && path != "") {
|
|
|
+ RandomUtil.delete(path.toString());
|
|
|
+ session.removeAttribute("path");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String str = information.getProjectId();
|
|
|
+ if (str.equals("")) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ String[] strArr = str.split("\\s+");
|
|
|
+ information.setAttrs(strArr);
|
|
|
+ }
|
|
|
+// Page<Information> page = informationService.findSearchPage(new Page<Information>(request, response), information,String[] strArr);
|
|
|
Page<Information> page = informationService.findPage(new Page<Information>(request, response), information);
|
|
|
return getBootstrapData(page);
|
|
|
}
|
|
@@ -125,7 +163,6 @@ public class InformationController extends BaseController {
|
|
|
}
|
|
|
|
|
|
//变更超期时间节点
|
|
|
- @RequiresPermissions(value={"modules:sg:information:information:add","modules:sg:information:information:edit"},logical=Logical.OR)
|
|
|
@RequestMapping(value = "updateConstant")
|
|
|
@ResponseBody
|
|
|
public String updateConstant(constant constant) {
|
|
@@ -139,36 +176,31 @@ public class InformationController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 导入甲供物资Excel数据
|
|
|
- */
|
|
|
- @RequiresPermissions("modules:sg:information:information:import")
|
|
|
- @ResponseBody
|
|
|
- @RequestMapping(value = "import")
|
|
|
- public AjaxJson importFile(@RequestParam("file")MultipartFile file, HttpServletResponse response, HttpServletRequest request) {
|
|
|
- AjaxJson j = new AjaxJson();
|
|
|
- try {
|
|
|
- StringBuilder failureMsg = new StringBuilder();
|
|
|
- ImportExcel ei = new ImportExcel(file, 1, 0);
|
|
|
-// List<Information> list = ei.getDataList(Information.class);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导入甲供物资和项目信息
|
|
|
+ */
|
|
|
+// @RequiresPermissions("modules:sg:information:information:import")
|
|
|
+ @ResponseBody
|
|
|
+ @RequestMapping(value = "importTwo")
|
|
|
+ public String importFile(MultipartFile btnCom,MultipartFile btnInformation, HttpServletResponse response, HttpServletRequest request) {
|
|
|
+ try {
|
|
|
+ ImportExcel importExcel = new ImportExcel(btnInformation, 1, 0);
|
|
|
+ int excelLastDataRowNum = importExcel.getLastDataRowNum();
|
|
|
+ Map<String, Integer> importCom = ImportInformation.importCom(importExcel, excelLastDataRowNum);
|
|
|
+ ImportExcel ei = new ImportExcel(btnCom, 1, 0);
|
|
|
int lastDataRowNum = ei.getLastDataRowNum();
|
|
|
Map<String, Object> information = ImportInformation.importmation(ei, lastDataRowNum);
|
|
|
- //获取失败条数
|
|
|
- int failureNum = Integer.parseInt(information.get("failureNum").toString());
|
|
|
- //获取成功条数
|
|
|
- int successNum = Integer.parseInt(information.get("successNum").toString());
|
|
|
-
|
|
|
- if (failureNum>0){
|
|
|
- failureMsg.insert(0, ",失败 "+failureNum+" 项目管理记录。");
|
|
|
- }
|
|
|
- j.setMsg( "已成功导入 "+successNum+" 项目管理记录;"+failureMsg);
|
|
|
- } catch (Exception e) {
|
|
|
- j.setSuccess(false);
|
|
|
- j.setMsg("导入项目管理信息失败!失败信息:"+e.getMessage());
|
|
|
- }
|
|
|
- return j;
|
|
|
+ Record record = new Record();
|
|
|
+ recordService.save(record);
|
|
|
+ return "插入成功";
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.getMessage();
|
|
|
+ return "插入失败";
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 导入综合信息Excel数据
|
|
|
* */
|
|
@@ -197,6 +229,37 @@ public class InformationController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 导入甲供物资Excel数据
|
|
|
+ */
|
|
|
+ @RequiresPermissions("modules:sg:information:information:import")
|
|
|
+ @ResponseBody
|
|
|
+ @RequestMapping(value = "import")
|
|
|
+ public AjaxJson importFile(@RequestParam("file")MultipartFile file, HttpServletResponse response, HttpServletRequest request) {
|
|
|
+ AjaxJson j = new AjaxJson();
|
|
|
+ try {
|
|
|
+ StringBuilder failureMsg = new StringBuilder();
|
|
|
+ ImportExcel ei = new ImportExcel(file, 1, 0);
|
|
|
+// List<Information> list = ei.getDataList(Information.class);
|
|
|
+ int lastDataRowNum = ei.getLastDataRowNum();
|
|
|
+ Map<String, Object> information = ImportInformation.importmation(ei, lastDataRowNum);
|
|
|
+ //获取失败条数
|
|
|
+ int failureNum = Integer.parseInt(information.get("failureNum").toString());
|
|
|
+ //获取成功条数
|
|
|
+ int successNum = Integer.parseInt(information.get("successNum").toString());
|
|
|
+
|
|
|
+ if (failureNum>0){
|
|
|
+ failureMsg.insert(0, ",失败 "+failureNum+" 项目管理记录。");
|
|
|
+ }
|
|
|
+ j.setMsg( "已成功导入 "+successNum+" 项目管理记录;"+failureMsg);
|
|
|
+ } catch (Exception e) {
|
|
|
+ j.setSuccess(false);
|
|
|
+ j.setMsg("导入项目管理信息失败!失败信息:"+e.getMessage());
|
|
|
+ }
|
|
|
+ return j;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@RequiresPermissions("modules:sg:information:information:import")
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "importInTrial")
|
|
@@ -220,6 +283,7 @@ public class InformationController extends BaseController {
|
|
|
return j;
|
|
|
}
|
|
|
|
|
|
+ //批量查询
|
|
|
@RequiresPermissions("modules:sg:information:information:import")
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "btnSearch")
|
|
@@ -247,8 +311,15 @@ public class InformationController extends BaseController {
|
|
|
}
|
|
|
List<Information> listBy = informationService.findListBy(infor);
|
|
|
try {
|
|
|
+ HttpSession session = request.getSession();
|
|
|
+ Object oldPath = session.getAttribute("path");
|
|
|
+ if (oldPath != null && oldPath != "") {
|
|
|
+ RandomUtil.delete(oldPath.toString());
|
|
|
+ session.removeAttribute("path");
|
|
|
+ }
|
|
|
File path = new File(this.getClass().getResource("/").getPath()+"/freemarker");
|
|
|
- File temp =new File(path+"\\information");
|
|
|
+ String fileName = RandomUtil.getRandomFileName();
|
|
|
+ File temp =new File(path+"\\"+fileName);
|
|
|
/**
|
|
|
* 在临时文件中写入内容
|
|
|
*/
|
|
@@ -383,10 +454,11 @@ public class InformationController extends BaseController {
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- HttpSession session = request.getSession();
|
|
|
- Object path = session.getAttribute("path");
|
|
|
+
|
|
|
List<Information> tList = new ArrayList<>();
|
|
|
AjaxJson j = new AjaxJson();
|
|
|
+ HttpSession session = request.getSession();
|
|
|
+ Object path = session.getAttribute("path");
|
|
|
if (path != null && path != "") {
|
|
|
// * 读取临时文件中的内容
|
|
|
BufferedReader bufferedReader = null;
|