xs преди 5 години
родител
ревизия
294c338821

+ 25 - 0
src/main/java/com/jeeplus/modules/sg/managementcenter/materialplan/entity/Storage.java

@@ -0,0 +1,25 @@
+package com.jeeplus.modules.sg.managementcenter.materialplan.entity;
+
+/**
+ * 是否入库
+ */
+public class Storage {
+    private String uniqueCode;//物资唯一码(批次编码)
+    private String flagStorage;//是否入库
+
+    public String getUniqueCode() {
+        return uniqueCode;
+    }
+
+    public void setUniqueCode(String uniqueCode) {
+        this.uniqueCode = uniqueCode;
+    }
+
+    public String getFlagStorage() {
+        return flagStorage;
+    }
+
+    public void setFlagStorage(String flagStorage) {
+        this.flagStorage = flagStorage;
+    }
+}

+ 35 - 0
src/main/java/com/jeeplus/modules/sg/managementcenter/materialplan/service/MaterialPlanService.java

@@ -10,10 +10,17 @@ import com.jeeplus.modules.sg.managementcenter.materialplan.entity.MaterialPlan;
 import com.jeeplus.modules.sg.managementcenter.materialplan.mapper.MaterialPlanMapper;
 import com.jeeplus.modules.sg.managementcenter.project.entity.Project;
 import com.jeeplus.modules.sg.managementcenter.project.mapper.ProjectMapper;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URLEncoder;
 import java.util.List;
 
 @Service
@@ -66,4 +73,32 @@ public class MaterialPlanService extends CrudService<MaterialPlanMapper, Materia
 		materialPlan.preUpdate();
 		materialPlanMapper.updateTime(materialPlan);
 	}
+
+	public void exportHeard( HttpServletResponse response){
+		InputStream inputStream = null;
+		XSSFWorkbook workbook = null;
+		try {
+			String path = (getSispPath() + "excelmodel/flagstorage.xlsx");
+			File file = new File(path);
+			inputStream = new FileInputStream(file);// 将excel文件转为输入流
+			workbook = new XSSFWorkbook(inputStream);// 创建个workbook,
+			String str = URLEncoder.encode("是否入库模板.xlsx", "UTF8");
+			OutputStream outputStream = response.getOutputStream();
+			response.reset();
+			response.setHeader("Content-Disposition", "attachment;filename="+str);
+			response.setContentType("application/vnd.ms-excel;charset=UTF-8");
+			workbook.write(outputStream);
+			outputStream.flush();
+			outputStream.close();
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+		}
+	}
+
+
+	public  String getSispPath() {
+		String sispPath = this.getClass().getResource("/").getPath()+ "freemarker/";
+		return sispPath;
+	}
 }

+ 72 - 8
src/main/java/com/jeeplus/modules/sg/managementcenter/materialplan/util/MaterialPlanInfo.java

@@ -1,6 +1,7 @@
 package com.jeeplus.modules.sg.managementcenter.materialplan.util;
 import com.jeeplus.modules.sg.managementcenter.materialplan.entity.InventoryTable;
 import com.jeeplus.modules.sg.managementcenter.materialplan.entity.MaterialPlan;
+import com.jeeplus.modules.sg.managementcenter.materialplan.entity.Storage;
 import groovy.util.IFileNameFinder;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.formula.functions.T;
@@ -15,9 +16,13 @@ public class MaterialPlanInfo {
     public static final Integer MATER_TWO = 2;
     public static final Integer MATER_THREE = 3;
     public static final Integer MATER_FOUR = 4;
-    public static final String MATER_CODE = "物资唯一码";
+    public static final String MATER_CODE = "物资唯一码";
     public static final String MATER_CODETWO = "批次编码";
     public static final String MATER_NUMBER = "序号";
+    public static final String MATER_FLAG = "入库";
+    public static final String MATER_MATERIAL="物料";
+    public static final String MATER_YES = "是";
+    public static final String MATER_NO = "否";
 //    public static final String MATER_STORAGE = "是否入库";
 //    public static final String MATER_COUNT = "库存数量";
 //    public static final String MATER_DONGCOUNT = "冻结数量";
@@ -84,30 +89,73 @@ public class MaterialPlanInfo {
     }
 
     /**
+     * 导入是否入库
+     */
+    public static List<Storage> getFlagStorage(ImportUtil importUtil)  {
+        int lastRow = importUtil.getLastDataRowNum();
+        List<Storage> list = new ArrayList<Storage>();
+        Storage storage = null;
+        String uniqueCode="";//费用估算
+        for(int i=1; i<lastRow;i++){
+            storage = new Storage();
+            Row row = importUtil.getRow(i);
+            uniqueCode = (String)importUtil.getCellValue(row,0);
+            if (StringUtils.isNotBlank(uniqueCode)){
+                storage.setUniqueCode(uniqueCode);
+                storage.setFlagStorage((String)importUtil.getCellValue(row,1));
+                list.add(storage);
+            }
+        }
+        return list;
+    }
+    /**
      * 判断excel是哪张表
      * @return
      */
     public static Integer getJudgeExcel(ImportUtil importUtil){
         Row row = importUtil.getRow(0);
         String firstName = (String) importUtil.getCellValue(row,0);
+        String basicTwoName = (String) importUtil.getCellValue(row,2);
+        String twoName = (String)importUtil.getCellValue(row,1);
+        String fourName = (String)importUtil.getCellValue(row,4);
         if (firstName.contains(MATER_CODE)||firstName.contains(MATER_CODETWO)){
-            return MATER_ONE;
+           if (basicTwoName.contains(MATER_MATERIAL)){
+               return MATER_ONE;
+           }
+            if (twoName.contains(MATER_FLAG)){
+                return MATER_THREE;
+            }
         }
-        if (firstName.contains(MATER_NUMBER)){
+        if (firstName.contains(MATER_NUMBER)&&fourName.contains(MATER_MATERIAL)){
             return MATER_TWO;
         }
         return MATER_FOUR;
     }
 
     /**
-     * 获取新的数据系列
+     * 判断是否入库符合规范
+     * @param importUtil
+     * @return
+     */
+    public static boolean getJudeStorage(ImportUtil importUtil){
+        boolean flag = false;
+        List<Storage> flagStorage = MaterialPlanInfo.getFlagStorage(importUtil);
+        if (null!=flagStorage&&flagStorage.size()>0){
+            for (Storage storage:flagStorage){
+                if (!storage.getFlagStorage().equals(MATER_YES)&&!storage.getFlagStorage().equals(MATER_NO)){
+                    flag = true;
+                    break;
+                }
+            }
+        }
+        return flag;
+    }
+    /**
+     * 获取库存数据
      * @return
      */
     public static List<MaterialPlan> getUpdateMaterPlan(List<MaterialPlan> materialPlanList,ImportUtil importUtil){
         List<InventoryTable> inventoryTableList = MaterialPlanInfo.getInventoryTableUtil(importUtil);
-        for (InventoryTable inventoryTable:inventoryTableList){
-            System.out.println(inventoryTable);
-        }
         for (MaterialPlan materialPlan:materialPlanList){
             for (InventoryTable inventoryTable:inventoryTableList){
                 if (materialPlan.getUniqueCode().equals(inventoryTable.getUniqueCode())){
@@ -116,12 +164,28 @@ public class MaterialPlanInfo {
                     materialPlan.setSupplierName(inventoryTable.getSupplierName());
                 }
             }
-            System.out.println("qweqweqw====="+materialPlan);
         }
         return materialPlanList;
     }
 
     /**
+     * 获取是否入库数据
+     * @param materialPlanList
+     * @param importUtil
+     * @return
+     */
+    public static List<MaterialPlan> getUpdateMaterPlanStorage(List<MaterialPlan> materialPlanList,ImportUtil importUtil){
+        List<Storage> flagStorage = MaterialPlanInfo.getFlagStorage(importUtil);
+        for (MaterialPlan materialPlan:materialPlanList){
+            for (Storage storage:flagStorage){
+                if (materialPlan.getUniqueCode().equals(storage.getUniqueCode())){
+                    materialPlan.setFlagStorage(storage.getFlagStorage());
+                }
+            }
+        }
+        return materialPlanList;
+    }
+    /**
      * 生成随机数
      * @return
      */

+ 74 - 18
src/main/java/com/jeeplus/modules/sg/managementcenter/materialplan/web/MeterialPlanController.java

@@ -18,6 +18,7 @@ import com.jeeplus.modules.sg.managementcenter.project.entity.Project;
 import com.jeeplus.modules.sg.managementcenter.project.service.ProjectService;
 import com.jeeplus.modules.sg.managementcenter.project.util.ProExcelInfo;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
@@ -173,25 +174,35 @@ public class MeterialPlanController extends BaseController {
     @RequestMapping(value = "import")
    	public AjaxJson importFile(@RequestParam("file")MultipartFile file, HttpServletResponse response, HttpServletRequest request) throws IOException, InvalidFormatException {
 		AjaxJson j = new AjaxJson();
-//		try {
+		MaterialPlan material = new MaterialPlan();
+		List<MaterialPlan> materialPlanList = materialPlanService.findAllList(material);
+		if (null==materialPlanList&&materialPlanList.size()<=0){
+			j.setSuccess(false);
+			j.setMsg( "还没有导入基础数据表");
+			return j;
+		}
+		try {
+			Integer count = 0;
 			int successNum = 0;
 			int failureNum = 0;
 			StringBuilder failureMsg = new StringBuilder();
 			ImportUtil importUtil = new ImportUtil(file,0,0);
 			Integer integer = MaterialPlanInfo.getJudgeExcel(importUtil);//验证表
-
-			System.out.println(integer);
-			if (integer==1){
-				List<MaterialPlan> materialPlans = MaterialPlanInfo.getMaterPlanUtil(importUtil);
-				materialPlanService.saveList(materialPlans);
+			if (integer==MaterialPlanInfo.MATER_FOUR){
+				j.setSuccess(false);
+				j.setMsg("表不符合规范,请重新导入");
+				return j;
 			}
-			if (integer==2){
-				MaterialPlan material = new MaterialPlan();
-				List<MaterialPlan> materialPlanList = materialPlanService.findAllList(material);
-				if (null==materialPlanList&&materialPlanList.size()<=0){
-					j.setMsg( "还没有导入基础数据表");
-					return j;
+			if (integer==MaterialPlanInfo.MATER_ONE){
+				List<MaterialPlan> materialPlans = MaterialPlanInfo.getMaterPlanUtil(importUtil);
+				try{
+					materialPlanService.saveList(materialPlans);
+					count = materialPlans.size();
+				}catch (Exception e){
+					e.printStackTrace();
 				}
+			}
+			if (integer==MaterialPlanInfo.MATER_TWO){
 				List<MaterialPlan> updateMaterPlans = MaterialPlanInfo.getUpdateMaterPlan(materialPlanList, importUtil);
 				for (MaterialPlan updateMaterPlan:updateMaterPlans){
 					try{
@@ -204,14 +215,41 @@ public class MeterialPlanController extends BaseController {
 					}
 				}
 			}
+			if (integer == MaterialPlanInfo.MATER_THREE){
+				boolean judeStorage = MaterialPlanInfo.getJudeStorage(importUtil);
+				if (judeStorage){
+					j.setSuccess(false);
+					j.setMsg( "是否入库表不符合规范");
+					return j;
+				}
+				List<MaterialPlan> updateMaterPlanStorage = MaterialPlanInfo.getUpdateMaterPlanStorage(materialPlanList, importUtil);
+				for (MaterialPlan updateStorage:updateMaterPlanStorage){
+					try{
+						materialPlanService.update(updateStorage);
+						successNum++;
+					}catch(ConstraintViolationException ex){
+						failureNum++;
+					}catch (Exception ex) {
+						failureNum++;
+					}
+				}
+			}
 			if (failureNum>0){
-				failureMsg.insert(0, ",失败 "+failureNum+" 条项目表单记录。");
+				failureMsg.insert(0, ",失败 "+failureNum+" 条项记录。");
+			}
+			if (integer == MaterialPlanInfo.MATER_ONE){
+				j.setMsg( "已成功导入 "+count+" 条基本表记录"+failureMsg);
+			}
+			if (integer == MaterialPlanInfo.MATER_TWO){
+				j.setMsg( "已成功导入 "+successNum+" 条库存表记录"+failureMsg);
 			}
-			j.setMsg( "已成功导入");
-//		} catch (Exception e) {
-//			j.setSuccess(false);
-//			j.setMsg("导入失败!失败信息:"+e.getMessage());
-//		}
+			if (integer == MaterialPlanInfo.MATER_THREE){
+				j.setMsg( "已成功导入 "+successNum+" 条是否入库记录"+failureMsg);
+			}
+		} catch (Exception e) {
+			j.setSuccess(false);
+			j.setMsg("导入失败!失败信息:"+e.getMessage());
+		}
 		return j;
     }
 	@ResponseBody
@@ -230,4 +268,22 @@ public class MeterialPlanController extends BaseController {
 		j.setMsg("时间不符合规范");
 		return j;
 	}
+
+	/**
+	 * 下载导入数据模板
+	 */
+	@ResponseBody
+	@RequestMapping(value = "import/template")
+	public AjaxJson importFileTemplate(HttpServletResponse response) {
+		AjaxJson j = new AjaxJson();
+		try {
+			materialPlanService.exportHeard(response);
+			j.setSuccess(true);
+			j.setMsg("导出成功!");
+		} catch (Exception e) {
+			j.setSuccess(false);
+			j.setMsg( "导入模板下载失败!失败信息:"+e.getMessage());
+		}
+		return j;
+	}
 }

BIN
src/main/resources/freemarker/excelmodel/flagstorage.xlsx


+ 10 - 10
src/main/webapp/webpage/modules/sg/financial/erp/erpCreditList.jsp

@@ -42,16 +42,21 @@
 					<i class="glyphicon glyphicon-plus"></i> 新建
 				</button>
 			<%--</shiro:hasPermission>--%>
+				<%--<shiro:hasPermission name="test:onetomany:dialog:testDataMain1:del">--%>
+				<button id="remove" class="btn btn-danger" disabled onclick="deleteAll()">
+					<i class="glyphicon glyphicon-remove"></i> 删除
+				</button>
+				<%--</shiro:hasPermission>--%>
 			<%--<shiro:hasPermission name="test:onetomany:dialog:testDataMain1:edit">--%>
 			    <button id="edit" class="btn btn-success" disabled onclick="edit()">
 	            	<i class="glyphicon glyphicon-edit"></i> 修改
 	        	</button>
 			<%--</shiro:hasPermission>--%>
-			<%--<shiro:hasPermission name="test:onetomany:dialog:testDataMain1:del">--%>
-				<button id="remove" class="btn btn-danger" disabled onclick="deleteAll()">
-	            	<i class="glyphicon glyphicon-remove"></i> 删除
-	        	</button>
-			<%--</shiro:hasPermission>--%>
+				<%--<shiro:hasPermission name="test:onetomany:dialog:testDataMain1:view">--%>
+				<button id="view" class="btn btn-default" onclick="view()">
+					<i class="fa fa-search-plus"></i> 查看
+				</button>
+				<%--</shiro:hasPermission>--%>
 			<%--<shiro:hasPermission name="test:onetomany:dialog:testDataMain1:import">--%>
 				<button id="btnImport" class="btn btn-info"><i class="fa fa-folder-open-o"></i> 导入</button>
 			<%--</shiro:hasPermission>--%>
@@ -60,11 +65,6 @@
 					<i class="fa fa-file-excel-o"></i> 导出
 				</button>
 			 <%--</shiro:hasPermission>--%>
-			<%--<shiro:hasPermission name="test:onetomany:dialog:testDataMain1:view">--%>
-				<button id="view" class="btn btn-default" onclick="view()">
-					<i class="fa fa-search-plus"></i> 查看
-				</button>
-			<%--</shiro:hasPermission>--%>
 		    </div>
 		
 	<!-- 表格 -->

+ 1 - 1
src/main/webapp/webpage/modules/sg/managementcenter/materialplan/materialplanForm.jsp

@@ -2,7 +2,7 @@
 <%@ include file="/webpage/include/taglib.jsp"%>
 <html>
 <head>
-	<title>工程表单管理</title>
+	<title>物料计划管理</title>
 	<meta name="decorator" content="ani"/>
 	<script type="text/javascript">
 

+ 7 - 6
src/main/webapp/webpage/modules/sg/managementcenter/materialplan/materialplanList.js

@@ -215,7 +215,6 @@ $(document).ready(function() {
 				"<div class='input-group form_datetime deliverySchedule' id="+row.uniqueCode+"  onclick=\"listDate( '" + row.uniqueCode +" ')\"> <input type='text'   name='deliverySchedule' class='form-control required'  value=''/> <span class='input-group-addon'> <span class='glyphicon glyphicon-calendar'></span> </span></div>" ,
 			].join('');
 		}
-
 	  if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){//如果是移动端
 
 		 
@@ -260,7 +259,9 @@ $(document).ready(function() {
 	 $("#export").click(function(){//导出Excel文件
 			jp.downloadFile('${ctx}/sg/managementcenter/materialplan/export');
 	  });
-
+        $("#export1").click(function(){//导出Excel文件
+            jp.downloadFile('${ctx}/sg/managementcenter/materialplan/import/template');
+        });
 		    
 	  $("#search").click("click", function() {// 绑定查询按扭
 		  $('#materialPlanTable').bootstrapTable('refresh');
@@ -292,7 +293,7 @@ $(document).ready(function() {
     }
   
   function deleteAll(){
-		jp.confirm('确认要删除该项目管理表单记录吗?', function(){
+		jp.confirm('确认要删除该物料计划表单记录吗?', function(){
           jp.loading();
           jp.get("${ctx}/sg/managementcenter/materialplan/deleteAll?ids=" + getIdSelections(), function(data){
               if(data.success){
@@ -311,7 +312,7 @@ $(document).ready(function() {
   }
   
    function add(){
-	  jp.openSaveDialog('新增项目管理表单', "${ctx}/sg/managementcenter/materialplan/form",'800px', '500px');
+	  jp.openSaveDialog('新增物料计划表单', "${ctx}/sg/managementcenter/materialplan/form",'800px', '500px');
   }
 
 
@@ -320,14 +321,14 @@ $(document).ready(function() {
        if(id == undefined){
 	      id = getIdSelections();
 	}
-	jp.openSaveDialog('编辑项目管理表单', "${ctx}/sg/managementcenter/materialplan/form?id=" + id, '800px', '500px');
+	jp.openSaveDialog('编辑物料计划表单', "${ctx}/sg/managementcenter/materialplan/form?id=" + id, '800px', '500px');
   }
   
  function view(id){//没有权限时,不显示确定按钮
       if(id == undefined){
              id = getIdSelections();
       }
-        jp.openViewDialog('查看项目管理表单', "${ctx}/sg/managementcenter/materialplan/form?id=" + id, '800px', '500px');
+        jp.openViewDialog('查看物料计划表单', "${ctx}/sg/managementcenter/materialplan/form?id=" + id, '800px', '500px');
  }
 
 

+ 13 - 10
src/main/webapp/webpage/modules/sg/managementcenter/materialplan/materialplanList.jsp

@@ -40,28 +40,31 @@
 				<button id="add" class="btn btn-primary" onclick="add()">
 					<i class="glyphicon glyphicon-plus"></i> 新建
 				</button>
+				<%--</shiro:hasPermission>--%>
+				<%--<shiro:hasPermission name="test:one:dialog:leave1:del">--%>
+				<button id="remove" class="btn btn-danger" disabled onclick="deleteAll()">
+					<i class="glyphicon glyphicon-remove"></i> 删除
+				</button>
 			<%--</shiro:hasPermission>--%>
 			<%--<shiro:hasPermission name="test:one:dialog:leave1:edit">--%>
 			    <button id="edit" class="btn btn-success" disabled onclick="edit()">
 	            	<i class="glyphicon glyphicon-edit"></i> 修改
 	        	</button>
-			<%--</shiro:hasPermission>--%>
-			<%--<shiro:hasPermission name="test:one:dialog:leave1:del">--%>
-				<button id="remove" class="btn btn-danger" disabled onclick="deleteAll()">
-	            	<i class="glyphicon glyphicon-remove"></i> 删除
-	        	</button>
+				<%--</shiro:hasPermission>--%>
+				<%--<shiro:hasPermission name="test:one:dialog:leave1:view">--%>
+				<button id="view" class="btn btn-default" disabled onclick="view()">
+					<i class="fa fa-search-plus"></i> 查看
+				</button>
 			<%--</shiro:hasPermission>--%>
 			<%--<shiro:hasPermission name="test:one:dialog:leave1:import">--%>
 				<button id="btnImport" class="btn btn-info"><i class="fa fa-folder-open-o"></i> 导入</button>
 			<%--</shiro:hasPermission>--%>
 			<%--<shiro:hasPermission name="test:one:dialog:leave1:export">--%>
-	        		<button id="export" class="btn btn-warning">
+				<button id="export" class="btn btn-warning">
 					<i class="fa fa-file-excel-o"></i> 导出
 				</button>
-			 <%--</shiro:hasPermission>--%>
-	                 <%--<shiro:hasPermission name="test:one:dialog:leave1:view">--%>
-				<button id="view" class="btn btn-default" disabled onclick="view()">
-					<i class="fa fa-search-plus"></i> 查看
+				<button id="export1" class="btn btn-warning">
+					<i class="fa fa-file-excel-o"></i> 导出入库模板
 				</button>
 			<%--</shiro:hasPermission>--%>
 		    </div>

+ 11 - 10
src/main/webapp/webpage/modules/sg/managementcenter/project/projectList.jsp

@@ -41,16 +41,21 @@
 					<i class="glyphicon glyphicon-plus"></i> 新建
 				</button>
 			<%--</shiro:hasPermission>--%>
+				<%--<shiro:hasPermission name="test:one:dialog:leave1:del">--%>
+				<button id="remove" class="btn btn-danger" disabled onclick="deleteAll()">
+					<i class="glyphicon glyphicon-remove"></i> 删除
+				</button>
+				<%--</shiro:hasPermission>--%>
 			<%--<shiro:hasPermission name="test:one:dialog:leave1:edit">--%>
 			    <button id="edit" class="btn btn-success" disabled onclick="edit()">
 	            	<i class="glyphicon glyphicon-edit"></i> 修改
 	        	</button>
 			<%--</shiro:hasPermission>--%>
-			<%--<shiro:hasPermission name="test:one:dialog:leave1:del">--%>
-				<button id="remove" class="btn btn-danger" disabled onclick="deleteAll()">
-	            	<i class="glyphicon glyphicon-remove"></i> 删除
-	        	</button>
-			<%--</shiro:hasPermission>--%>
+				<%--<shiro:hasPermission name="test:one:dialog:leave1:view">--%>
+				<button id="view" class="btn btn-default" disabled onclick="view()">
+					<i class="fa fa-search-plus"></i> 查看
+				</button>
+				<%--</shiro:hasPermission>--%>
 			<%--<shiro:hasPermission name="test:one:dialog:leave1:import">--%>
 				<button id="btnImport" class="btn btn-info"><i class="fa fa-folder-open-o"></i> 导入</button>
 			<%--</shiro:hasPermission>--%>
@@ -59,11 +64,7 @@
 					<i class="fa fa-file-excel-o"></i> 导出
 				</button>
 			 <%--</shiro:hasPermission>--%>
-	                 <%--<shiro:hasPermission name="test:one:dialog:leave1:view">--%>
-				<button id="view" class="btn btn-default" disabled onclick="view()">
-					<i class="fa fa-search-plus"></i> 查看
-				</button>
-			<%--</shiro:hasPermission>--%>
+
 		    </div>
 		
 	<!-- 表格 -->