|
@@ -3,21 +3,25 @@
|
|
*/
|
|
*/
|
|
package com.jeeplus.modules.sg.information.web;
|
|
package com.jeeplus.modules.sg.information.web;
|
|
|
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
|
-import java.util.Date;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+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.validation.ConstraintViolationException;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
|
+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.service.InformationService;
|
|
import com.jeeplus.modules.sg.information.service.InformationService;
|
|
-import com.jeeplus.modules.sg.material.entity.Material;
|
|
|
|
|
|
+import com.jeeplus.modules.sg.information.utils.ImportInformation;
|
|
import com.jeeplus.modules.sg.material.service.MaterialService;
|
|
import com.jeeplus.modules.sg.material.service.MaterialService;
|
|
|
|
+import io.swagger.models.auth.In;
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
|
+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.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
@@ -38,14 +42,14 @@ import com.jeeplus.common.utils.excel.ImportExcel;
|
|
* @version
|
|
* @version
|
|
*/
|
|
*/
|
|
@Controller
|
|
@Controller
|
|
-@RequestMapping(value = "${adminPath}/sg/information/information")
|
|
|
|
|
|
+@RequestMapping(value = "${adminPath}/sg/information")
|
|
public class InformationController extends BaseController {
|
|
public class InformationController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private InformationService informationService;
|
|
private InformationService informationService;
|
|
@Autowired
|
|
@Autowired
|
|
private MaterialService materialService;
|
|
private MaterialService materialService;
|
|
-
|
|
|
|
|
|
+
|
|
@ModelAttribute
|
|
@ModelAttribute
|
|
public Information get(@RequestParam(required=false) String id) {
|
|
public Information get(@RequestParam(required=false) String id) {
|
|
Information entity = null;
|
|
Information entity = null;
|
|
@@ -57,7 +61,7 @@ public class InformationController extends BaseController {
|
|
}
|
|
}
|
|
return entity;
|
|
return entity;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 项目管理列表页
|
|
* 项目管理列表页
|
|
*/
|
|
*/
|
|
@@ -67,7 +71,7 @@ public class InformationController extends BaseController {
|
|
model.addAttribute("informationList", information);
|
|
model.addAttribute("informationList", information);
|
|
return "modules/sg/information/informationList";
|
|
return "modules/sg/information/informationList";
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 项目管理列表数据
|
|
* 项目管理列表数据
|
|
*/
|
|
*/
|
|
@@ -79,6 +83,7 @@ public class InformationController extends BaseController {
|
|
return getBootstrapData(page);
|
|
return getBootstrapData(page);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
@RequestMapping(value = "form")
|
|
@RequestMapping(value = "form")
|
|
public String form(Information information, Model model) {
|
|
public String form(Information information, Model model) {
|
|
model.addAttribute("Information", information);
|
|
model.addAttribute("Information", information);
|
|
@@ -97,97 +102,28 @@ public class InformationController extends BaseController {
|
|
public AjaxJson importFile(@RequestParam("file")MultipartFile file, HttpServletResponse response, HttpServletRequest request) {
|
|
public AjaxJson importFile(@RequestParam("file")MultipartFile file, HttpServletResponse response, HttpServletRequest request) {
|
|
AjaxJson j = new AjaxJson();
|
|
AjaxJson j = new AjaxJson();
|
|
try {
|
|
try {
|
|
- int successNum = 0;
|
|
|
|
- int failureNum = 0;
|
|
|
|
- int inforNum = 0;
|
|
|
|
|
|
+
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
|
|
+ StringBuilder failInformation = new StringBuilder();
|
|
ImportExcel ei = new ImportExcel(file, 1, 0);
|
|
ImportExcel ei = new ImportExcel(file, 1, 0);
|
|
// List<Information> list = ei.getDataList(Information.class);
|
|
// List<Information> list = ei.getDataList(Information.class);
|
|
int lastDataRowNum = ei.getLastDataRowNum();
|
|
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++;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ Map<String, Object> information = ImportInformation.importmation(ei, lastDataRowNum);
|
|
|
|
+ int failureNum = Integer.parseInt(information.get("failureNum").toString());
|
|
|
|
+ int successNum = Integer.parseInt(information.get("successNum").toString());
|
|
|
|
+ List<Information> informationList= (List<Information>)information.get("importmation");
|
|
if (failureNum>0){
|
|
if (failureNum>0){
|
|
failureMsg.insert(0, ",失败 "+failureNum+" 项目管理记录。");
|
|
failureMsg.insert(0, ",失败 "+failureNum+" 项目管理记录。");
|
|
}
|
|
}
|
|
- j.setMsg( "已成功导入 "+successNum+" 项目管理记录"+failureMsg);
|
|
|
|
- j.setMsg( "已成功导入 "+inforNum+" 项目管理记录"+failureMsg);
|
|
|
|
|
|
+ if (informationList != null) {
|
|
|
|
+ if (informationList.size() >0) {
|
|
|
|
+ for (Information in :informationList) {
|
|
|
|
+ failInformation.append(in.getProjectName()+";");
|
|
|
|
+ }
|
|
|
|
+ failInformation.append("以上物料因出库数量与数据库中不一致未能插入");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ 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());
|
|
@@ -203,36 +139,16 @@ public class InformationController extends BaseController {
|
|
public AjaxJson importFileCom(@RequestParam("file")MultipartFile file, HttpServletResponse response, HttpServletRequest request) {
|
|
public AjaxJson importFileCom(@RequestParam("file")MultipartFile file, HttpServletResponse response, HttpServletRequest request) {
|
|
AjaxJson j = new AjaxJson();
|
|
AjaxJson j = new AjaxJson();
|
|
try {
|
|
try {
|
|
- int successNum = 0;
|
|
|
|
- int failureNum = 0;
|
|
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
ImportExcel ei = new ImportExcel(file, 1, 0);
|
|
ImportExcel ei = new ImportExcel(file, 1, 0);
|
|
int lastDataRowNum = ei.getLastDataRowNum();
|
|
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++;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ Map<String, Integer> importCom = ImportInformation.importCom(ei, lastDataRowNum);
|
|
|
|
+ int failureNum = importCom.get("failureNum");
|
|
|
|
+ int successNum = importCom.get("successNum");
|
|
if (failureNum>0){
|
|
if (failureNum>0){
|
|
- failureMsg.insert(0, ",失败 "+failureNum+" 审定日期记录。");
|
|
|
|
|
|
+ failureMsg.insert(0, ",失败 "+failureNum+" 项目管理记录。");
|
|
}
|
|
}
|
|
- j.setMsg( "已成功导入 "+successNum+" 审定日期记录"+failureMsg);
|
|
|
|
|
|
+ j.setMsg( "已成功导入 "+successNum+" 项目管理记录"+failureMsg);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
j.setSuccess(false);
|
|
j.setSuccess(false);
|
|
j.setMsg("导入项审定日期失败!失败信息:"+e.getMessage());
|
|
j.setMsg("导入项审定日期失败!失败信息:"+e.getMessage());
|
|
@@ -240,6 +156,59 @@ public class InformationController extends BaseController {
|
|
return j;
|
|
return j;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 批量导入模板
|
|
|
|
+ * */
|
|
|
|
+ @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("", Information.class, 1).setDataList(list).write(response, fileName).dispose();
|
|
|
|
+ return null;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ j.setSuccess(false);
|
|
|
|
+ j.setMsg( "批量项目查询下载失败!失败信息:"+e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ return j;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping(value = "btnSearch")
|
|
|
|
+ public Map<String, Object> btnSearch(@RequestParam("file")MultipartFile file, Information information, HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
|
+ AjaxJson j = new AjaxJson();
|
|
|
|
+ StringBuilder failureMsg = new StringBuilder();
|
|
|
|
+ ImportExcel ei = null;
|
|
|
|
+ try {
|
|
|
|
+ ei = new ImportExcel(file, 1, 0);
|
|
|
|
+ }catch (Exception e) {
|
|
|
|
+ j.setSuccess(false);
|
|
|
|
+ j.setMsg("导入项审定日期失败!失败信息:"+e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ int lastDataRowNum = ei.getLastDataRowNum();
|
|
|
|
+ List<Information> infor = new ArrayList<>();
|
|
|
|
+ for (int i = 1; i < lastDataRowNum; i++) {
|
|
|
|
+ Information information1 = new Information();
|
|
|
|
+ Row row = ei.getRow(i);
|
|
|
|
+ Object projectId = ei.getCellValue(row, 0);
|
|
|
|
+ Object projectName = ei.getCellValue(row, 1);
|
|
|
|
+ information1.setProjectId(projectId.toString());
|
|
|
|
+ information1.setProjectName(projectName.toString());
|
|
|
|
+ infor.add(information1);
|
|
|
|
+ }
|
|
|
|
+ List<Information> listBy = informationService.findListBy(infor);
|
|
|
|
+ String listCount = String.valueOf(listBy.size());
|
|
|
|
+ long l = Long.parseLong(listCount);
|
|
|
|
+ Page<Information> page = new Page(1, listBy.size(), l, listBy);
|
|
|
|
+ List<Information> list = page.getList();
|
|
|
|
+ long count = page.getCount();
|
|
|
|
+ return getBootstrapData(page);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
-}
|
|
|