|
@@ -0,0 +1,258 @@
|
|
|
|
+/**
|
|
|
|
+ * Copyright © 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
|
|
|
|
+ */
|
|
|
|
+package com.jeeplus.modules.test.information.web;
|
|
|
|
+
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import javax.validation.ConstraintViolationException;
|
|
|
|
+
|
|
|
|
+import com.jeeplus.modules.test.information.entity.Information;
|
|
|
|
+import com.jeeplus.modules.test.information.material.entity.Material;
|
|
|
|
+import com.jeeplus.modules.test.information.material.service.MaterialService;
|
|
|
|
+import com.jeeplus.modules.test.information.service.InformationService;
|
|
|
|
+import com.sun.tools.javac.util.Convert;
|
|
|
|
+import io.swagger.models.auth.In;
|
|
|
|
+import net.sourceforge.jtds.jdbc.DateTime;
|
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
|
+import org.apache.shiro.authz.annotation.Logical;
|
|
|
|
+import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
|
+import org.springframework.ui.Model;
|
|
|
|
+import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
+
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
|
+import com.jeeplus.common.utils.DateUtils;
|
|
|
|
+import com.jeeplus.common.config.Global;
|
|
|
|
+import com.jeeplus.common.json.AjaxJson;
|
|
|
|
+import com.jeeplus.core.persistence.Page;
|
|
|
|
+import com.jeeplus.core.web.BaseController;
|
|
|
|
+import com.jeeplus.common.utils.StringUtils;
|
|
|
|
+import com.jeeplus.common.utils.excel.ExportExcel;
|
|
|
|
+import com.jeeplus.common.utils.excel.ImportExcel;
|
|
|
|
+import com.jeeplus.modules.test.onetomany.dialog.entity.TestDataMain1;
|
|
|
|
+import com.jeeplus.modules.test.onetomany.dialog.service.TestDataMain1Service;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 项目管理列表Controller
|
|
|
|
+ * @author
|
|
|
|
+ * @version
|
|
|
|
+ */
|
|
|
|
+@Controller
|
|
|
|
+@RequestMapping(value = "${adminPath}/test/information/information")
|
|
|
|
+public class InformationController extends BaseController {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private InformationService informationService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private MaterialService materialService;
|
|
|
|
+
|
|
|
|
+ @ModelAttribute
|
|
|
|
+ public Information get(@RequestParam(required=false) String id) {
|
|
|
|
+ Information entity = null;
|
|
|
|
+ if (StringUtils.isNotBlank(id)){
|
|
|
|
+ entity = informationService.get(id);
|
|
|
|
+ }
|
|
|
|
+ if (entity == null){
|
|
|
|
+ entity = new Information();
|
|
|
|
+ }
|
|
|
|
+ return entity;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 项目管理列表页
|
|
|
|
+ */
|
|
|
|
+ //@RequiresPermissions("test:information:information:list")
|
|
|
|
+ @RequestMapping(value = {"list", ""})
|
|
|
|
+ public String list(Information information, Model model) {
|
|
|
|
+ model.addAttribute("informationList", information);
|
|
|
|
+ return "modules/test/information/informationList";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 项目管理列表数据
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ //@RequiresPermissions("test:onetomany:dialog:testDataMain1:list")
|
|
|
|
+ @RequestMapping(value = "data")
|
|
|
|
+ public Map<String, Object> data(Information information, HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
|
+ Page<Information> page = informationService.findPage(new Page<Information>(request, response), information);
|
|
|
|
+ return getBootstrapData(page);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @RequestMapping(value = "form")
|
|
|
|
+ public String form(Information information, Model model) {
|
|
|
|
+ model.addAttribute("Information", information);
|
|
|
|
+ return "modules/test/information/informationForm";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 导入欠供物资Excel数据
|
|
|
|
+ */
|
|
|
|
+ //@RequiresPermissions("test:onetomany:dialog:information:import")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping(value = "import")
|
|
|
|
+ public AjaxJson importFile(@RequestParam("file")MultipartFile file, HttpServletResponse response, HttpServletRequest request) {
|
|
|
|
+ AjaxJson j = new AjaxJson();
|
|
|
|
+ try {
|
|
|
|
+ int successNum = 0;
|
|
|
|
+ int failureNum = 0;
|
|
|
|
+ int inforNum = 0;
|
|
|
|
+ StringBuilder failureMsg = new StringBuilder();
|
|
|
|
+ ImportExcel ei = new ImportExcel(file, 1, 0);
|
|
|
|
+// List<Information> list = ei.getDataList(Information.class);
|
|
|
|
+ int lastDataRowNum = ei.getLastDataRowNum();
|
|
|
|
+ for (int i = 1; i < lastDataRowNum; i++) {
|
|
|
|
+ try {
|
|
|
|
+ Row row = ei.getRow(i);
|
|
|
|
+ Object projectId = ei.getCellValue(row, 1);
|
|
|
|
+ Object projectName = ei.getCellValue(row, 2);
|
|
|
|
+ Object inforId = ei.getCellValue(row, 3);
|
|
|
|
+ Object materialName = ei.getCellValue(row, 4);
|
|
|
|
+ Object outboundAmount = ei.getCellValue(row, 5);
|
|
|
|
+ Object authorizedAmount = ei.getCellValue(row, 6);
|
|
|
|
+ Object difference = ei.getCellValue(row, 7);
|
|
|
|
+ Object outboundNumber = ei.getCellValue(row, 8);
|
|
|
|
+ Object authorizedNumber = ei.getCellValue(row, 9);
|
|
|
|
+ Object price = ei.getCellValue(row, 11);
|
|
|
|
+ Object unit = ei.getCellValue(row, 12);
|
|
|
|
+ Object materialSmall = ei.getCellValue(row, 13);
|
|
|
|
+ Object materialMid = ei.getCellValue(row, 14);
|
|
|
|
+ Object materialBig = ei.getCellValue(row, 15);
|
|
|
|
+ Object Flag = ei.getCellValue(row, 10);
|
|
|
|
+ Object department = ei.getCellValue(row, 16);
|
|
|
|
+ Object secondUnits = ei.getCellValue(row, 17);
|
|
|
|
+ Object firstUnits = ei.getCellValue(row, 18);
|
|
|
|
+ String isBack = "";
|
|
|
|
+ if (Flag.equals("0")) {
|
|
|
|
+ isBack = "是";
|
|
|
|
+ } else {
|
|
|
|
+ isBack = "否";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (outboundAmount.equals("")) {
|
|
|
|
+ outboundAmount = "0.0";
|
|
|
|
+ }
|
|
|
|
+ if (authorizedAmount.equals("")) {
|
|
|
|
+ authorizedAmount = "0.0";
|
|
|
|
+ }
|
|
|
|
+ if (difference.equals("")) {
|
|
|
|
+ difference = "0.0";
|
|
|
|
+ }
|
|
|
|
+ if (outboundNumber.equals("")) {
|
|
|
|
+ outboundNumber = "0.0";
|
|
|
|
+ }
|
|
|
|
+ if (authorizedNumber.equals("")) {
|
|
|
|
+ authorizedNumber = "0.0";
|
|
|
|
+ }
|
|
|
|
+ if (price.equals("")) {
|
|
|
|
+ price = "0.0";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Material material = new Material();
|
|
|
|
+ material.setInforId(inforId.toString());
|
|
|
|
+ material.setProjectId(projectId.toString());
|
|
|
|
+ material.setMaterialName(materialName.toString());
|
|
|
|
+ material.setOutboundAmount(Double.parseDouble(outboundAmount.toString()));
|
|
|
|
+ material.setAuthorizedAmount(Double.parseDouble(authorizedAmount.toString()));;
|
|
|
|
+ material.setDifference(Double.parseDouble(difference.toString()));
|
|
|
|
+ material.setOutboundNumber(Double.parseDouble(outboundNumber.toString()));
|
|
|
|
+ material.setAuthorizedNumber(Double.parseDouble(authorizedNumber.toString()));
|
|
|
|
+ material.setPrice(Double.parseDouble(price.toString()));
|
|
|
|
+ material.setUnit(unit.toString());
|
|
|
|
+ material.setMaterialSmall(materialSmall.toString());
|
|
|
|
+ material.setMaterialMid(materialMid.toString());
|
|
|
|
+ material.setMaterialBig(materialBig.toString());
|
|
|
|
+ material.setIsBack(isBack);
|
|
|
|
+ materialService.save(material);
|
|
|
|
+ inforNum++;
|
|
|
|
+ Information information2 = new Information();
|
|
|
|
+ information2.setProjectId(projectId.toString());
|
|
|
|
+ information2.setProjectName(projectName.toString());
|
|
|
|
+ information2.setDepartment(department.toString());
|
|
|
|
+ information2.setSecondUnits(secondUnits.toString());
|
|
|
|
+ information2.setFirstUnits(firstUnits.toString());
|
|
|
|
+ informationService.save(information2);
|
|
|
|
+ successNum++;
|
|
|
|
+ } catch(ConstraintViolationException ex){
|
|
|
|
+ failureNum++;
|
|
|
|
+ }catch (Exception ex) {
|
|
|
|
+ failureNum++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (failureNum>0){
|
|
|
|
+ failureMsg.insert(0, ",失败 "+failureNum+" 项目管理记录。");
|
|
|
|
+ }
|
|
|
|
+ j.setMsg( "已成功导入 "+successNum+" 项目管理记录"+failureMsg);
|
|
|
|
+ j.setMsg( "已成功导入 "+inforNum+" 项目管理记录"+failureMsg);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ j.setSuccess(false);
|
|
|
|
+ j.setMsg("导入项目管理信息失败!失败信息:"+e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ return j;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 导入综合信息Excel数据
|
|
|
|
+ * */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping(value = "importCom")
|
|
|
|
+ public AjaxJson importFileCom(@RequestParam("file")MultipartFile file, HttpServletResponse response, HttpServletRequest request) {
|
|
|
|
+ AjaxJson j = new AjaxJson();
|
|
|
|
+ try {
|
|
|
|
+ int successNum = 0;
|
|
|
|
+ int failureNum = 0;
|
|
|
|
+ StringBuilder failureMsg = new StringBuilder();
|
|
|
|
+ ImportExcel ei = new ImportExcel(file, 1, 0);
|
|
|
|
+ int lastDataRowNum = ei.getLastDataRowNum();
|
|
|
|
+ for (int i = 2; i < lastDataRowNum; i++) {
|
|
|
|
+ try {
|
|
|
|
+ Row row = ei.getRow(i);
|
|
|
|
+ Object projectId = ei.getCellValue(row, 1);
|
|
|
|
+ Object projectName = ei.getCellValue(row, 2);
|
|
|
|
+ Object appDate = ei.getCellValue(row, 44);
|
|
|
|
+ Information information2 = new Information();
|
|
|
|
+ information2.setProjectId(projectId.toString());
|
|
|
|
+ information2.setProjectName(projectName.toString());
|
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ Date parse = simpleDateFormat.parse(appDate.toString());
|
|
|
|
+ simpleDateFormat.format(parse);
|
|
|
|
+ information2.setApprovalDate(parse);
|
|
|
|
+ informationService.updateInformationDate(information2);
|
|
|
|
+ successNum++;
|
|
|
|
+ } catch(ConstraintViolationException ex){
|
|
|
|
+ failureNum++;
|
|
|
|
+ }catch (Exception ex) {
|
|
|
|
+ failureNum++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (failureNum>0){
|
|
|
|
+ failureMsg.insert(0, ",失败 "+failureNum+" 审定日期记录。");
|
|
|
|
+ }
|
|
|
|
+ j.setMsg( "已成功导入 "+successNum+" 审定日期记录"+failureMsg);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ j.setSuccess(false);
|
|
|
|
+ j.setMsg("导入项审定日期失败!失败信息:"+e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ return j;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|