java- 供应商申请记录 关于新旧表单展示 新增变更数据逻辑小案例

曾经做过一个小功能 供应商申请记录  有新增的供应商申请记录和变更的供应商申请记录 都要进行审核   有保存和驳回 操作。

话不多说,上代码。  

 

 

1-这是供应商申请记录的一个list 列表数据展示

/**
 * @Title:供应商异常申请类Controller
 * @Description:
 * @Author:cenwei
 * @Since:2018-05-22 17:57:22
 * @Version:1.1.0
 * @Copyright:Copyright (c) 浙江蘑菇加电子商务有限公司 2015 ~ 2016 版权所有  
 */
@Controller
@RequestMapping("/assets/goods/supplier_apply")
public class SupplierApplyController extends BaseController {
   private static Logger logger = Logger.getLogger(SupplierApplyController.class);
   
   @Resource
   private ISupplierApplyService supplierApplyService;

   @Resource
   private ISupplierService supplierService;

   @Resource
   private ISupplierBankService supplierBankService;
   
   //列表
   @RequestMapping("/list")
   public String list(ModelMap model,String sessionId) {
      model.addAttribute("sessionId", sessionId);
      return "/goods/supplier_apply_list";
   }

   @ResponseBody
   @RequestMapping("/ajaxList")
   public String ajaxList(SupplierApply supplierApply, Query query, String sessionId) {
      PagerModel<SupplierApply> pm = null;
      try {
         pm = this.supplierApplyService.getPagerModelByQuery(supplierApply, query);
      } catch (Exception e) {
         logger.error("SupplierApplyController-ajaxList:"+e);
         e.printStackTrace();
      }
      return JsonUtils.toJson(pm);
   }

 

2-申请单处理 确定操作

 @ResponseBody
@RequestMapping("/pass")
public String Pass(String id,Supplier supplierVo,HttpServletRequest request ,String sessionId) {

       SupplierApply supplierApply=null;
       //新插入的供应商
   Supplier newSupplier=null;
       //原始存在的供应商
   Supplier supplier =null;

       SimpleReturnVo returnVo = new SimpleReturnVo(ERROR, "保存失败");

   try {
           User user = this.getLoginUser(sessionId);
           if (null != user && StringUtils.isNotBlank(user.getUsername())) {
                    String userName=user.getUsername();

              if (StringUtils.isNotBlank(id)) {

               //新增的供应商对象
               supplier = this.supplierService.getSupplierById(id);
                       newSupplier = this.supplierService.getSupplierById(id);

                       supplierApply = this.supplierApplyService.getSupplierApplyByspId(newSupplier.getId());


                       List<SupplierBank> newSupplierBanks = this.supplierBankService.getSupplierBanksByspId(id);



                       //如果是新增的申请单  要新插入有用的数据
                       if(SupplierApplyEnum.XZ.getType().equals(supplierApply.getApplyType())) {

                  //新生成uuid 供应商   插入数据库

                  newSupplier.setId(UUIDGenerator.generate());
               // List<SupplierBank> bankList= new ArrayList<SupplierBank>();
                  for (SupplierBank supplierBank :newSupplierBanks){

                     supplierBank.setId(UUIDGenerator.generate());
                     supplierBank.setSupplierId(newSupplier.getId());
                     supplierBank.setUpdateTime(new Date());
                     supplierBank.setUpdator(userName);
                  // bankList.add(supplierBank);
                  }

                  this.supplierBankService.insertSupplierBankBatch(newSupplierBanks);


                           newSupplier.setIsReal(1);
                           newSupplier.setStatus(1);

                           supplierApply.setSupplierId(newSupplier.getId());

                  newSupplier.setCode(supplierVo.getCode());
                           supplier.setCode(supplierVo.getCode());
                  supplierApply.setRemark(supplierVo.getRemark());
                  newSupplier.setUpdateTime(new Date());
                  newSupplier.setUpdator(userName);
                           this.supplierService.updateSupplier(supplier);
                           this.supplierService.addSupplier(newSupplier);

                        //如果是变更的申请单 要改之前供应商数据 以及银行数据
                       }else{
                           //获得根据传过来的newid 得到新表单的对象
                           Supplier newsupplier = this.supplierService.getSupplierById(id);

                           //获得原始有效的供应商对象
                   supplier =this.supplierService.getSupplierById(supplierApply.getSupplierId());

                           //更新supplier里面的银行数据 根据supplierId 将原始的银行数据都删除  再重新添加新的银行数据 关联supplierId
                  //首先将原始供应商的对象的所有银行数据删除

                  this.supplierBankService.delSupplierBankBySupplierId(supplier.getId());

                           for (SupplierBank supplierBank :newSupplierBanks){
                               supplierBank.setId(UUIDGenerator.generate());
                               supplierBank.setSupplierId(supplier.getId());
                               supplierBank.setUpdateTime(new Date());
                               supplierBank.setUpdator(userName);
                           }

                  this.supplierBankService.insertSupplierBankBatch(newSupplierBanks);

                           supplier.setIsReal(1);
                           supplier.setName(newSupplier.getName());
                           supplier.setTaxNumber(newSupplier.getTaxNumber());
                           supplier.setUpdator(userName);
                           supplier.setUpdateTime(new Date());
                       // supplierApply.setSupplierId(supplier.getId());

                           supplier.setCode(supplierVo.getCode());
                           newsupplier.setCode(supplierVo.getCode());
                           supplierApply.setRemark(supplierVo.getRemark());
                           supplier.setUpdateTime(new Date());
                           supplier.setUpdator(userName);

                           this.supplierService.updateSupplier(newsupplier);
                           this.supplierService.updateSupplier(supplier);

                       }

                       supplierApply.setApplyStatus(SupplierApplyEnum.YTG.getType());
                       supplierApply.setUpdator(userName);
                       supplierApply.setUpdateTime(new Date());

                       this.supplierApplyService.updateSupplierApply(supplierApply);

               returnVo = new SimpleReturnVo(SUCCESS, "保存成功");
                          }


           }else{
               returnVo = new SimpleReturnVo(ERROR, "用户信息获取失败,请重新登录");

           }

   }catch(Exception e){
          logger.error("SupplierApplyController-pass:"+e);
          e.printStackTrace();
       }
             return JsonUtils.toJson(returnVo);

}

 

3-申请单驳回操作

@ResponseBody
@RequestMapping("/reject")
public String reject( SupplierApply supplierApplyVo,String sessionId,HttpServletRequest request)  {
       SimpleReturnVo returnVo = new SimpleReturnVo(ERROR, "驳回失败");
   try{
           User user = this.getLoginUser(sessionId);
           if (null != user && StringUtils.isNotBlank(user.getUsername())) {
                String userName = user.getUsername();
                   if(supplierApplyVo!=null){

           SupplierApply  supplierApply =this.supplierApplyService.getSupplierApplyByspId(supplierApplyVo.getNewSupplierId());
           supplierApply.setApplyStatus(SupplierApplyEnum.YBH.getType());
           supplierApply.setFeedback(supplierApplyVo.getFeedback());

           supplierApplyService.updateSupplierApply(supplierApply);
           returnVo = new SimpleReturnVo(SUCCESS, "驳回成功");
            }
           }else{
               returnVo = new SimpleReturnVo(ERROR, "用户信息获取失败,请重新登录");
           }
   } catch (Exception e) {
      logger.error("SupplierApplyController-noPass:" + e);
      e.printStackTrace();
   }
   return JsonUtils.toJson(returnVo);
}

 

 

4-点击申请记录表单的 “处理”操作的 一个表单(或是新增或是变更的新旧表单)展示

 

@RequestMapping("/input")
public String input(ModelMap model,String id,String sessionId) {

   try {
      if(StringUtils.isNotBlank(id)){
         SupplierApply supplierApply=this.supplierApplyService.getSupplierApplyById(id);

         if (SupplierApplyEnum.BG.getType().equals(supplierApply.getApplyType())) {
            Supplier oldSupplier = this.supplierService.getSupplierById(supplierApply.getOldSupplierId());
            Supplier newSupplier = this.supplierService.getSupplierById(supplierApply.getNewSupplierId());

            model.addAttribute("oldSupplier", oldSupplier);
            model.addAttribute("newSupplier", newSupplier);

            model.addAttribute("sessionId", sessionId);
                   model.addAttribute("SupplierApply", supplierApply);

            return "/goods/supplier_apply_inputss";


         }else {
            //属于新增类型的申请单 只有一条供应商数据
            Supplier supplier = this.supplierService.getSupplierById(supplierApply.getNewSupplierId());
            model.addAttribute("supplier", supplier);

            model.addAttribute("sessionId", sessionId);
                   model.addAttribute("SupplierApply", supplierApply);
                       return "/goods/supplier_apply_input";

         }

      }
   } catch (Exception e) {
      logger.error("SupplierApplyController-input:"+e);
      e.printStackTrace();
   }


       return null;
}

 

 

 

下面上一些前段页面的代码

1-这是供应商申请记录表的页面

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>供应商异常申请类管理</title>
<#include "/share/include.ftl" />
<#import "/share/toolbar_common.ftl" as tolbcom/>
<#assign name_space='supplier_apply'>
<script type="text/javascript" language="javascript" src="${BasePath}/resources/js/goods/supplier_apply.js"></script>
<script>
   var _jsSessionId='${sessionId!''}'; //sessionId
   /**
    * 初始化操作按钮
    * @param value
    * @param row
    * @param index
    * @returns {String}
    */
   function optsFormatter(value, row, index) {
      var returnMsg="";
      var id = row.id;
      var  status = row.applyStatus;
      console.info(status);
      if(status=="SQZ"){
      var update=<#if checkPrivileges(sessionId,systemSn,name_space,2) == true>'<a href="javascript:void(0)" class="easyui-linkbutton" style="color: blue;" iconCls="icon-del" plain="true" οnclick="supplier_apply.edit(\''
         + id + '\')">处理</a>&nbsp;&nbsp;'<#else>''</#if>;
      var select=<#if checkPrivileges(sessionId,systemSn,name_space,2) == true>'<a href="javascript:void(0)" class="easyui-linkbutton" style="color: blue;" iconCls="icon-del" plain="true" οnclick="supplier_apply.select(\''
         + id + '\')">查看</a>&nbsp;&nbsp;'<#else>''</#if>;
      
      returnMsg = update + select;
      } else{
        var select=<#if checkPrivileges(sessionId,systemSn,name_space,2) == true>'&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp<a href="javascript:void(0)" class="easyui-linkbutton" style="color: blue;" iconCls="icon-del" plain="true" οnclick="supplier_apply.select(\''
                + id + '\')">查看</a>&nbsp;&nbsp;'<#else>''</#if>;
            returnMsg = select;
      }

      var delFlag = row.delFlag;
      if(delFlag==0){
         returnMsg="";
      }
      return returnMsg;
   }
   function parsePage() {
      supplier_apply.init();
   };
</script>
</head>
<body class="easyui-layout">

   <div data-options="region:'north',border:false">
      <div id="toolbar" class="easyui-toolbar">
         <#if checkPrivileges(sessionId,systemSn,name_space,0) == true>
         <a href="javascript:void(0)"  iconCls="icon-refresh" plain="true" id="jsRefresh">刷新</a>
         <a>-</a>
         </#if>
         <#if checkPrivileges(sessionId,systemSn,name_space,2) == true>
         <a href="javascript:void(0)"  iconCls="icon-edit" plain="true" id="jsEdit">处理</a>
         <a>-</a>
         </#if>

         <#--<#if checkPrivileges(sessionId,systemSn,name_space,3) == true>
         <a href="javascript:void(0)"  iconCls="icon-del" plain="true" id="jsDel">删除</a>
         <a>-</a>
         </#if>-->

      </div>









      <#if checkPrivileges(sessionId,systemSn,name_space,1) == true>


         <div class="search-div">
                <form name="searchForm" id="searchForm" action="" method="post" οnsubmit="return false;">
                    <table class="search-tb" >
                        <col width="100" />
                        <col />
                        <col width="100" />
                        <col />
                        <col width="100" />
                        <col />
                        <tbody>
                        <tr>
                            <th>供应商名称 :</th>
                            <td>
                                <input class="ipt jsClearValue" name="nameTmp" style="width: 150px;" />
                            </td>
                            <th>供应商编码 :</th>
                            <td>
                                <input class="ipt jsClearValue" name="codeTmp" style="width: 150px;" />
                            </td>
                            <th>审批状态:</th>
                            <td>
                                <select id="cc" class="easyui-combobox" name="applyStatus" style="width: 100px;">
                                    <option value="">全部</option>
                                    <option value="SQZ">申请中</option>
                                    <option value="YTG">已通过</option>
                                    <option value="YBH">已驳回</option>
                                    <option value="WTJ">未提交</option>
                                </select>
                            </td>

                            <td>
                                <a iconCls="icon-search" class="easyui-linkbutton ml10" id="SearchBtn" data-options="iconCls:'icon-search'">查询</a>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </form>
            </div>
      </#if>
   </div>
   <!--列表start-->
   <div data-options="region:'center',border:false">
      <table id="subDg" class="easyui-datagrid" data-options="collapsible : true,rownumbers:true,pagination : true,pageSize : 20,pageList : [ 20, 50,100 ],
         url :'${BasePath}/assets/goods/supplier_apply/ajaxList.do?sessionId=${sessionId!''}', method : 'post',singleSelect : false">
         <thead>
            <tr>
               <th data-options="field:'id',checkbox:true"></th>
                    <th data-options="field:'opt',width : 150,align:'left',formatter : optsFormatter">操作</th>
                    <th data-options="field:'applyNo',width : 150,align:'left'">申请单号</th>
                    <th data-options="field:'applyType',width : 150,align:'left',formatter:supplier_apply.applyTypeFormatter">申请类型</th>
               <th data-options="field:'applyStatus',width : 150,align:'left',formatter : supplier_apply.applyStatusFormatter,styler:supplier_apply.applyStatusStyler">审批状态</th>
               <th data-options="field:'applyManName',width : 150,align:'left'">申请人</th>
               <th data-options="field:'applyDept',width : 150,align:'left'">所属部门</th>

               <th data-options="field:'code',width : 150,align:'left'">供应商编码</th>
               <th data-options="field:'name',width : 300,align:'left'">供应商名称</th>
               <th data-options="field:'taxNumber',width : 150,align:'left'">纳税人识别号</th>
               <th data-options="field:'status',width : 100,align:'left',formatter : supplier_apply.statusFormatter,styler : supplier_apply.statusStyler">状态</th>
               <th data-options="field:'applyDate',width : 200,align:'left'">申请日期</th>
                    <th data-options="field:'remark',width : 150,align:'left'">备注</th>

               <th data-options="field:'createTime',width : 200,align:'left'">创建时间</th>
               <th data-options="field:'creator',width : 150,align:'left'">创建人</th>
               <th data-options="field:'updateTime',width : 200,align:'left'">修改时间</th>
               <th data-options="field:'updator',width : 150,align:'left'">修改人</th>

            </tr>
         </thead>
      </table> 
   </div>
   <!--列表end-->
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值