标签:经验分享 后勤报修项目 javaweb 材料入库管理 原码分享
楔子注意这个也可以作为注入,如果没有会出现空指针错误。
package com.wisdom.repair.web.management.materialManage; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.List; import java.util.Map; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.sql.DataSource; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; import com.wisdom.core.orm.BaseDao; import com.wisdom.core.security.domain.User; import com.wisdom.core.security.resource.SecurityUtils; import com.wisdom.core.utils.CollectionUtils; import com.wisdom.core.utils.Page; import com.wisdom.core.web.BaseController; import com.wisdom.example.commons.ValidationUtils; import com.wisdom.repair.entity.MaterialManage; import com.wisdom.repair.entity.RepairView; import com.wisdom.repair.entity.UploadType; import com.wisdom.repair.entity.pageBo.CodePageBo; import com.wisdom.repair.service.material.MaterialServiceImpl; import com.wisdom.repair.service.materialClass.MaterialClassServiceImpl; import com.wisdom.repair.service.materialManage.*; import com.wisdom.repair.service.pub.PublicService; import com.wisdom.repair.service.user.UserManageService; import com.wisdom.repair.web.management.user.UserPageBo; /** * * 类名称:MaterialManageController 类描述: 材料入库管理 创建人:Jxufe Kong De Wei 创建时间:2015-8-25 * 上午10:09:02 修改备注: * * @version */ @Controller("management.MaterialManageController") @RequestMapping("/management/materialManage/input") public class MaterialManageController extends BaseController { @Resource private MaterialManageService materialManageService; @Resource private MaterialServiceImpl materialService; @Resource private MaterialClassServiceImpl materialClassService; /** * * 方法名: list 方法作用: 列表显示 创建人:Jxufe Kong De Wei 创建时间:2015-8-25 上午10:14:44 * * @param @param request * @param @param page * @param @param bo * @param @return 返回值类型: String * @throws */ @RequestMapping("/list") public String list(HttpServletRequest request, Page page, CodePageBo bo) { /* * request.setAttribute("page",materialManageService. * getAllRepairByFilterBean(page, materialView)); */ bo.setInputType(1); request.setAttribute("page", materialManageService.getPageByFilterBean( page, "t_material_manage", MaterialManage.class, bo)); System.out.println(materialManageService.getPageByFilterBean(page, "t_material_manage", MaterialManage.class, bo)); return "/repair/management/materialManage/input/list"; } /** * * 方法名: add 方法作用: TODO 创建人:Jxufe Kong De Wei 创建时间:2015-8-25 上午10:14:38 * * @param @param request * @param @return 返回值类型: String * @throws */ @RequestMapping("/add") public String add(HttpServletRequest request) { List repTypeGroup = new ArrayList(); System.out.println("nihao"); try { request.setAttribute("id", materialManageService.createCode("t_material_manage")); request.setAttribute("repType", materialManageService .getCodeAll("t_code_repair_type_group")); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } return "/repair/management/materialManage/input/add"; } /** * * 方法名: materialClass 方法作用: 编辑界面获取三级联动默认值 创建人:Jxufe Kong De Wei * 创建时间:2015-8-26 上午11:15:04 * * @param @param value * @param @return * @param @throws Exception 返回值类型: List<List> * @throws */ @RequestMapping("/materialClass") @ResponseBody public List<List> materialClass(String value) throws Exception { System.out.println("11111111111input value" + value); List list = new ArrayList(); List listReturn = new ArrayList(); List listTop = new ArrayList(); listTop.add(""); listTop.add("--请选择--"); listReturn.add(listTop); if (value == null || value.isEmpty()) { return listReturn; } List list2 = new ArrayList(); list = materialClassService.getMaterialSubAll(value.trim()); for (int i = 0; i < list.size(); i++) { List listTemp = new ArrayList(); Map temMap = (Map) list.get(i); listTemp.add(temMap.get("code").toString().trim()); listTemp.add(temMap.get("name").toString().trim()); listReturn.add(listTemp); } return listReturn; } /** * * 方法名: material 方法作用: 编辑界面获取三级联动默认值 创建人:Jxufe Kong De Wei 创建时间:2015-8-26 * 上午11:15:41 * * @param @param value * @param @return * @param @throws Exception 返回值类型: List<List> * @throws */ @RequestMapping("/material") @ResponseBody public List<List> material(String value) throws Exception { System.out.println("1111111111111111111112input value" + value); List list = new ArrayList(); List listReturn = new ArrayList(); List listTop = new ArrayList(); listTop.add(""); listTop.add("--请选择--"); listReturn.add(listTop); if (value == null || value.isEmpty()) { return listReturn; } List list2 = new ArrayList(); list = materialService.getMaterialSubAll(value.trim()); for (int i = 0; i < list.size(); i++) { List listTemp = new ArrayList(); Map temMap = (Map) list.get(i); listTemp.add(temMap.get("code").toString().trim()); listTemp.add(temMap.get("name").toString().trim()); listReturn.add(listTemp); } return listReturn; } /** * * 方法名: edit 方法作用: 编辑 创建人:Jxufe Kong De Wei 创建时间:2015-8-25 上午10:14:06 * * @param @param request * @param @return 返回值类型: String * @throws */ @RequestMapping("/edit") public String edit(HttpServletRequest request) { /* * if(true) { ceshi(); return null; } else { */ List repTypeGroup = new ArrayList(); int code = Integer.parseInt(request.getParameter("id")); try { Map matairlManageMap = materialManageService.getAllByCode(code, "t_material_manage"); System.out.println(matairlManageMap); request.setAttribute("materialManage", matairlManageMap); request.setAttribute("repType", materialManageService .getCodeAll("t_code_repair_type_group")); request.setAttribute( "materialList", materialManageService.getMaterialList(matairlManageMap.get( "code_material").toString())); request.setAttribute("materialClassList", materialManageService .getMaterialClassList(matairlManageMap.get("code_material") .toString())); request.setAttribute("materialClassCode", materialManageService .getMaterialClassCode(matairlManageMap.get("code_material") .toString())); request.setAttribute( "groupCode", materialManageService.getGroupCode(matairlManageMap.get( "code_material").toString())); // request.setAttribute("topValue", // publicService.getCodeAll("t_code_repair_type_group")); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } return "/repair/management/materialManage/input/edit"; // } } public ModelAndView ceshi() { return ajaxDoneSuccess("123456789"); } /** * * 方法名: save 方法作用: 添加保存 创建人:Jxufe Kong De Wei 创建时间:2015-8-25 上午10:14:17 * * @param @param materialView * @param @param request * @param @return 返回值类型: ModelAndView * @throws */ @RequestMapping(value = "/save", method = RequestMethod.POST) public ModelAndView save(MaterialManage materialManage, HttpServletRequest request) { List<String> errors = ValidationUtils.validator(materialManage); Date nowDate = new Date(); if (errors != null) { request.setAttribute("errors", errors); return ajaxDoneError("失败!"); } else if (materialManage.getLoss_number() >= materialManage .getInput_number()) return ajaxDoneError("折旧数量不可超过入库数量!"); else { try { materialManage.setInputUser(SecurityUtils.getCurrentUserName()); materialManage.setInputTime(nowDate); materialManage.setInputType(1); materialManage.setControlTime(nowDate); System.out.println(materialManage.getId() + materialManage.getCodeMaterial() + materialManage.getBrands() + materialManage.getPrice() + materialManage.getInput_number() + materialManage.getInputType() + materialManage.getInputUser() + materialManage.getInputTime() + materialManage.getLoss_number() + materialManage.getMemo() + materialManage.getControlTime() + "00000000000000000000"); int info = materialManageService.saveCodeBean( "t_material_manage", materialManage.getId(), materialManage.getCodeMaterial(), materialManage.getBrands(), materialManage.getPrice(), materialManage.getInput_number(), materialManage.getInputType(), materialManage.getInputUser(), materialManage.getInputTime(), materialManage.getLoss_number(), materialManage.getMemo()); if (info > 0) { return ajaxDoneSuccess("成功!"); } else return ajaxDoneError("失败!"); } catch (Exception e) { return ajaxDoneError("失败!" + "<br/>系统报错信息:<br/>" + e.getMessage()); } } } /** * @throws Exception * * 方法名: update 方法作用: TODO 创建人:Jxufe Kong De Wei 创建时间:2015-8-25 * 上午10:14:23 * * @param @param materialView * @param @param request * @param @return 返回值类型: ModelAndView * @throws */ @RequestMapping(value = "/update", method = RequestMethod.POST) public ModelAndView update(MaterialManage materialManage, HttpServletRequest request) throws Exception { List<String> errors = ValidationUtils.validator(materialManage); Long day = returnDayDiffer(materialManageService.findMaterialById( materialManage.getId().longValue()).getInputTime()); if (errors != null) { request.setAttribute("errors", errors); return ajaxDoneError("失败!"); } else if (day > Integer.parseInt(materialManageService .findMaxLimitedById())) return ajaxDoneError("材料入库已超过 " + Integer.parseInt(materialManageService .findMaxLimitedById()) + " 日,数据不可更改!"); else if (materialManage.getLoss_number() >= materialManage .getInput_number()) return ajaxDoneError("折旧数量不可超过入库数量!"); else { try { materialManage.setInputType(1); /* * System.out.println(materialManage * .getId()+" "+materialManage. * getCodeMaterial()+" "+materialManage * .getBrands()+" "+materialManage .getPrice()+ * " "+materialManage * .getInput_number()+" "+materialManage.getInputType * ()+" "+materialManage.getInputUser()+" "+ * materialManage.getInputTime * ()+" "+materialManage.getLoss_number * ()+" "+materialManage.getMemo()+"111111111111111"); */ materialManageService.upateCodeBean("t_material_manage", materialManage.getId(), materialManage.getCodeMaterial(), materialManage.getBrands(), materialManage.getPrice(), materialManage.getInput_number(), materialManage.getInputType(), materialManage.getLoss_number(), materialManage.getMemo()); return ajaxDoneSuccess("成功!"); } catch (Exception e) { return ajaxDoneError("失败!" + "<br/>系统报错信息:<br/>" + e.getMessage()); } } } /** * * 方法名: delete 方法作用: 删除操作 创建人:Jxufe Kong De Wei 创建时间:2015-8-26 上午11:14:01 * * @param @param request * @param @return * @param @throws Exception 返回值类型: ModelAndView * @throws */ @RequestMapping("/delete") public ModelAndView delete(HttpServletRequest request) throws Exception { Integer id = Integer.parseInt(request.getParameter("id")); Long day = returnDayDiffer(materialManageService.findMaterialById( id.longValue()).getInputTime()); // System.out.println("8888888888888888888888888888"+day); if (day > Integer.parseInt(materialManageService.findMaxLimitedById())) { return ajaxDoneError("材料入库已超过 " + Integer.parseInt(materialManageService .findMaxLimitedById()) + " 日,数据不可更改!"); } else { int i = materialManageService.deleteById(id); if (i > 0) { return ajaxDoneSuccess("删除成功"); } else { return ajaxDoneError("删除失败"); } } } /** * * 方法名: returnDayDiffer 方法作用: 返回日期差 创建人:Jxufe Kong De Wei 创建时间:2015-8-26 * 上午11:13:34 * * @param @param date * @param @return 返回值类型: Long * @throws */ public Long returnDayDiffer(Date date) { Date nowDate = new Date(); long day = (nowDate.getTime() - date.getTime()) / (24 * 60 * 60 * 1000) > 0 ? (nowDate .getTime() - date.getTime()) / (24 * 60 * 60 * 1000) : (date.getTime() - nowDate.getTime()) / (24 * 60 * 60 * 1000); return day; } }
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%><%@ include file="/include.inc.jsp"%> <c:import url="../../_frag/pager/pagerForm.jsp"></c:import> <form method="post" rel="pagerForm" action="<c:url value='${base}/management/materialManage/input/list.htm'/>" onsubmit="return navTabSearch(this)"> <div class="pageHeader"> <div class="searchBar"> <ul class="searchContent"> <li><label>品牌:</label> <input type="text" name="brands" value="${param.brands}" /></li> </ul> <div class="subBar"> <ul> <li><div class="buttonActive"> <div class="buttonContent"> <button type="submit">查询</button> </div> </div> </li> </ul> </div> </div> </div> </form> <div class="pageContent"> <div class="panelBar"> <ul class="toolBar"> <li><a class="add" target="dialog" rel="addNav" href="<c:url value='/management/materialManage/input/add.htm'/>" title="添加记录"><span>添加</span> </a> </li> <li><a class="edit" target="dialog" rel="editNav" href="<c:url value='/management/materialManage/input/edit.htm?id={slt_objId}'/>" title="编辑记录"><span>编辑</span> </a> </li> <li><a class="delete" target="ajaxTodo" href="<c:url value='/management/materialManage/input/delete.htm?id={slt_objId}'/>" title="删除记录"><span>删除</span> </a> </li> <li class="line">line</li> </ul> </div> <table class="table" width="100%" layoutH="138"> <thead> <tr> <th width="50" orderField="ID" class="${param.orderField eq 'ID' ? param.orderDirection : ''}">代码</th> <th width="100" orderField="BRANDS" class="${param.orderField eq 'BRANDS' ? param.orderDirection : ''}">品牌</th> <th width="70" orderField="PRICE" class="${param.orderField eq 'PRICE' ? param.orderDirection : ''}">材料价格</th> <th width="70" orderField="input_number" class="${param.orderField eq 'input_number' ? param.orderDirection : ''}">入库数量</th> <th width="70" orderField="input_number" class="${param.orderField eq 'input_number' ? param.orderDirection : ''}">操作人员</th> <th width="90" orderField="input_number" class="${param.orderField eq 'input_number' ? param.orderDirection : ''}">入库时间</th> <th width="70" orderField="loss_number" class="${param.orderField eq 'loss_number' ? param.orderDirection : ''}">折旧数量</th> <th width="100" orderField="memo" class="${param.orderField eq 'memo' ? param.orderDirection : ''}">备注</th> <th width="120">服务器当前时间</th> </tr> </thead> <tbody> <jsp:useBean id="now" class="java.util.Date" /> <c:forEach var="MaterialManage" items="${page.result}" varStatus="s"> <tr target="slt_objId" rel="${MaterialManage.id}"> <td>${MaterialManage.id}</td> <td>${MaterialManage.brands}</td> <td>${MaterialManage.price}</td> <td>${MaterialManage.input_number}</td> <td>${MaterialManage.inputUser}</td> <td><fmt:formatDate value="${MaterialManage.inputTime}" pattern="yyyy-MM-dd HH:mm:ss" /> </td> <td>${MaterialManage.loss_number}</td> <td>${MaterialManage.memo}</td> <td><fmt:formatDate value="${now}" pattern="yyyy-MM-dd HH:mm:ss" /></td> </tr> </c:forEach> </tbody> </table> <c:import url="../../_frag/pager/panelBar.jsp"></c:import> </div>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%><%@ include file="/include.inc.jsp"%> <div class="pageContent"> <form method="post" action="<c:url value='/management/materialManage/input/save.htm?callbackType=closeCurrent'/>" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone)"> <div class="pageFormContent" layoutH="57"> <input type="hidden" id="id" name="id" value="${id}" remote="/management/public/checkUnique.htm?tableName=t_material_manage" class="required digits" /> <!-- <input type="button" value="重新生成" id="regenCode" style="padding:0px; margin: 0px 0px 0px 5px; "/> --> <div> <label>材料编号:</label> <select name="codeRepType" class="combox" ref="codeClaimerType" refUrl="${base}/management/materialManage/input/materialClass.htm?value={value}"> <option value="">--请选择--</option> <c:forEach var="ur" items="${repType}"> <option value="${ur.code}">${ur.name}</option> </c:forEach> </select> <select name="codeClaimerType" id="codeClaimerType" class="required combox" ref="codeMaterial" refUrl="${base}/management/materialManage/input/material.htm?value={value}"> <option value="">---请选择---</option> </select> <select name="codeMaterial" id="codeMaterial" class="required combox"> <option value="">--请选择--</option> </select> </div> <p> <label>品牌: </label> <input type="text" name="brands" class="required" maxlength="20" /> </p> <p> <label>价格: </label> <input type="text" name="price" class="required" maxlength="20" /> </p> <p> <label>入库数量: </label> <input type="text" name="input_number" max="9999" min="1" class="required textInput" maxlength="4" alt = "数据范围:1-9999"/> </p> <p> <label>折旧数量: </label> <input type="text" name="loss_number" id="loss_number12" max="9999" class="required" maxlength="4" alt = "折旧不得大于入库数量!"/> </p> <p> <label>备注: </label> <input type="text" name="memo" maxlength="20" /> </p> </div> <div class="formBar"> <ul> <li><div class="buttonActive"> <div class="buttonContent"> <button type="submit">保存</button> </div> </div></li> <li><div class="button"> <div class="buttonContent"> <button type="button" class="close">关闭</button> </div> </div></li> </ul> </div> </form> </div>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%><%@ include file="/include.inc.jsp"%> <div class="pageContent"> <form method="post" action="<c:url value='/management/materialManage/input/update.htm?callbackType=closeCurrent'/>" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone)"> <div class="pageFormContent" layoutH="57"> <input type="hidden" id="id" name="id" value="${materialManage.id}" remote="/management/public/checkUnique.htm?tableName=t_material_manage" class="required digits" /> <!-- <input type="button" value="重新生成" id="regenCode" style="padding:0px; margin: 0px 0px 0px 5px; "/> --> <div> <label>材料编号:</label> <select name="codeRepType" class="required combox" ref="codeClaimerType" refUrl="${base}/management/materialManage/input/materialClass.htm?value={value}"> <option value="">--请选择--</option> <c:forEach var="ur" items="${repType}"> <option value="${ur.code}" <c:if test="${ur.code==groupCode }"> selected </c:if>>${ur.name}</option> </c:forEach> </select> <select name="codeClaimerType" id="codeClaimerType" class="required combox" ref="codeMaterial" refUrl="${base}/management/materialManage/input/material.htm?value={value}"> <option value="">---请选择---</option> <c:forEach var="urclass" items="${materialClassList}"> <option value="${urclass.code}" <c:if test="${urclass.code==materialClassCode }"> selected </c:if>>${urclass.name}</option> </c:forEach> </select> <select name="codeMaterial" id="codeMaterial" class="required combox"> <option value="">--请选择--</option> <c:forEach var="urmaterial" items="${materialList}"> <option value="${urmaterial.code}" <c:if test="${urmaterial.code==materialManage.code_Material }"> selected </c:if>>${urmaterial.name}</option> </c:forEach> </select> </div> <p> <label>品牌: </label> <input type="text" name="brands" value="${materialManage.brands}" class="required" maxlength="20" /> </p> <p> <label>价格: </label> <input type="text" name="price" value="${materialManage.price}" class="required" maxlength="20" /> </p> <p> <label>入库数量: </label> <input type="text" name="input_number" value="${materialManage.input_number}" class="required" maxlength="4" /> </p> <p> <label>折旧数量: </label> <input type="text" name="loss_number" value="${materialManage.loss_number}" max="9999" class="required" maxlength="4" /> </p> <p> <label>备注: </label> <input type="text" name="memo" value="${materialManage.memo}" maxlength="20" /> </p> </div> <div class="formBar"> <ul> <li><div class="buttonActive"> <div class="buttonContent"> <button type="submit">保存</button> </div> </div> </li> <li><div class="button"> <div class="buttonContent"> <button type="button" class="close">关闭</button> </div> </div> </li> </ul> </div> </form> </div>
版权声明:转载请注明出处
标签:经验分享 后勤报修项目 javaweb 材料入库管理 原码分享
原文地址:http://blog.csdn.net/k183000860/article/details/48001669