瀏覽代碼

Merge remote-tracking branch 'origin/master'

xs 5 年之前
父節點
當前提交
fb04d634ef

+ 8 - 0
src/main/java/com/jeeplus/modules/sg/managementcenter/materialinfo/service/MaterialInfoService.java

@@ -25,6 +25,8 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 
 
@@ -107,6 +109,12 @@ public class MaterialInfoService extends CrudService<MaterialInfoMapper, Materia
 	public List<MaterialInfo> findByBatch(List<MaterialProject> list){
 		List<MaterialInfo> list1 = materialInfoMapper.findByList(list);
 		 List<MaterialInfo> list2 = getNewData(list1); //合并数据
+		Collections.sort(list2, new Comparator<MaterialInfo>() {
+			@Override
+			public int compare(MaterialInfo o1, MaterialInfo o2) {
+				return o1.getMaterialCode().compareTo(o2.getMaterialCode());
+			}
+		});
 		 return list2;
 	}
 

+ 5 - 5
src/main/java/com/jeeplus/modules/sg/managementcenter/materialinfo/web/MaterialInfoController.java

@@ -177,7 +177,7 @@ public class MaterialInfoController extends BaseController {
 	@RequestMapping(value = "importValidation")
 	public AjaxJson importValidation(@RequestParam("file")MultipartFile file,String batch) throws IOException, InvalidFormatException {
 		AjaxJson j = new AjaxJson();
-//		try {
+		try {
 		ImportExcel mo = new ImportExcel(file,1,"模块表");
 		Row row = mo.getRow(0);
 		String projectName1 = (String) mo.getCellValue(row, 1);
@@ -193,10 +193,10 @@ public class MaterialInfoController extends BaseController {
 			j.setErrorCode("0");
 			j.setMsg("导入成功");
 		}
-//		} catch (Exception e) {
-//			j.setSuccess(false);
-//			j.setMsg("导入失败!失败信息:"+e.getMessage());
-//		}
+		} catch (Exception e) {
+			j.setSuccess(false);
+			j.setMsg("导入失败!失败信息:"+e.getMessage());
+		}
 		return j;
 	}
 

+ 0 - 1
src/main/java/com/jeeplus/modules/sg/managementcenter/materialproject/entity/MaterialProject.java

@@ -77,7 +77,6 @@ public class MaterialProject extends DataEntity<MaterialProject> {
         this.projectBatch = projectBatch;
     }
 
-    @ExcelField(title="物料批次", align=2, sort=8)
     public String getSuppliesBatch() {
         return suppliesBatch;
     }

+ 26 - 6
src/main/java/com/jeeplus/modules/sg/managementcenter/materialproject/web/MaterialProjectController.java

@@ -149,22 +149,42 @@ public class MaterialProjectController extends BaseController {
     @RequestMapping(value = "export")
     public AjaxJson exportFile(MaterialProject materialProject, HttpServletRequest request, HttpServletResponse response) throws IOException {
 		AjaxJson j = new AjaxJson();
-//		try {
+		try {
             String fileName = "物料"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
             List<MaterialProject> list = materialProjectService.findList(materialProject);
             List<MaterialInfo> materialInfos = materialInfoService.findByBatch(list);
     		new ExportExcel(null, MaterialInfo.class).setDataList(materialInfos).write(response, fileName).dispose();
     		j.setSuccess(true);
     		j.setMsg("导出成功!");
-//    		return j;
-//		} catch (Exception e) {
-//			j.setSuccess(false);
-//			j.setMsg("导出失败!失败信息:"+e.getMessage());
-//		}
+    		return j;
+		} catch (Exception e) {
+			j.setSuccess(false);
+			j.setMsg("导出失败!失败信息:"+e.getMessage());
+		}
 			return j;
     }
 
 
+	@ResponseBody
+	@RequiresPermissions("managementcenter:materialproject:export")
+	@RequestMapping(value = "exportpro")
+	public AjaxJson exportPro(MaterialProject materialProject, HttpServletRequest request, HttpServletResponse response) {
+		AjaxJson j = new AjaxJson();
+		try {
+			String fileName = "项目列表"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
+			Page<MaterialProject> page = materialProjectService.findPage(new Page<MaterialProject>(request, response, -1), materialProject);
+			new ExportExcel(null, MaterialProject.class).setDataList(page.getList()).write(response, fileName).dispose();
+			j.setSuccess(true);
+			j.setMsg("导出成功!");
+			return j;
+		} catch (Exception e) {
+			j.setSuccess(false);
+			j.setMsg("导出失败!失败信息:"+e.getMessage());
+		}
+		return j;
+	}
+
+
 	
 
 

+ 1 - 1
src/main/resources/j2cache/j2cache.properties

@@ -89,7 +89,7 @@ redis.namespace =
 
 ## connection
 #redis.hosts = 127.0.0.1:6379
-redis.hosts = 192.168.2.4:6379
+redis.hosts = 192.168.2.4:6380
 redis.timeout = 2000
 redis.password =
 redis.database = 0

+ 5 - 0
src/main/webapp/webpage/modules/sg/managementcenter/materialproject/materialProjectList.js

@@ -156,6 +156,11 @@ $(document).ready(function() {
 			jp.downloadFile('${ctx}/managementcenter/materialproject/export?projectBatch='+batch);
 	  });
 
+    $("#exportpro").click(function(){//导出Excel文件
+         var batch = $("#bat").val();
+         jp.downloadFile('${ctx}/managementcenter/materialproject/exportpro?projectBatch='+batch);
+    });
+
 		    
 	  $("#search").click("click", function() {// 绑定查询按扭
 		  $('#dataTable').bootstrapTable('refresh');

+ 6 - 1
src/main/webapp/webpage/modules/sg/managementcenter/materialproject/materialProjectList.jsp

@@ -82,7 +82,7 @@
 			</shiro:hasPermission>
 			<shiro:hasPermission name="managementcenter:materialproject:export">
 	        		<button id="export" class="btn btn-warning">
-					<i class="fa fa-file-excel-o"></i> 导出
+					<i class="fa fa-file-excel-o"></i> 导出物料
 				</button>
 			 </shiro:hasPermission>
 	                 <shiro:hasPermission name="managementcenter:materialproject:view">
@@ -90,6 +90,11 @@
 					<i class="fa fa-search-plus"></i> 查看
 				</button>
 			</shiro:hasPermission>
+				<shiro:hasPermission name="managementcenter:materialproject:export">
+					<button id="exportpro" class="btn btn-warning">
+						<i class="fa fa-file-excel-o"></i> 导出项目
+					</button>
+				</shiro:hasPermission>
 		    </div>
 		
 	<!-- 表格 -->