SSH-------------自动填充客户信息\保存业务通知单\自动分单
1、页面展示
输入电话,查询crm系统的名字,客户编号,地址,也返回了decidedzone_id
之后缺staff_id字段,无法分单
因此,根据decidedzone_id,查询bc_decidedzone表 根据decidedzone_id能查到staff_id,把值赋给qp_noticebill,因此所有页面中的值包括staff_id和user_id都存到了该表中
2、jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>添加业务受理单</title> <!-- 导入jquery核心类库 --> <script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.8.3.js"></script> <!-- 导入easyui类库 --> <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/js/easyui/themes/default/easyui.css"> <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/js/easyui/themes/icon.css"> <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/js/easyui/ext/portal.css"> <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/default.css"> <script type="text/javascript" src="${pageContext.request.contextPath }/js/easyui/jquery.easyui.min.js"></script> <script type="text/javascript" src="${pageContext.request.contextPath }/js/easyui/ext/jquery.portal.js"></script> <script type="text/javascript" src="${pageContext.request.contextPath }/js/easyui/ext/jquery.cookie.js"></script> <script src="${pageContext.request.contextPath }/js/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script> <script type="text/javascript"> $(function(){ $("body").css({visibility:"visible"}); ////////////////////////// // 对save按钮条件 点击事件 $('#save').click(function(){ // 对form 进行校验 if($('#noticebillForm').form('validate')){ $('#noticebillForm').submit(); } }); //////////////////////// $("input[name=telephone]").blur(function () { //失去焦点事件 var tel=$("input[name=telephone]").val(); var url="${pageContext.request.contextPath}/noticeBillAction_findCustomerByTelephone.action"; //{"address":"上海","decidedzone_id":"","id":2,"name":"李四","station":"哇哈哈","telephone":"2"} $.post(url,{tel:tel},function (data) { if(data != null){ $("input[name=customerId]").val(data.id); $("input[name=customerName]").val(data.name); $("input[name=pickaddress]").val(data.address); $("input[name=delegater]").val(data.name); $("input[name=decodeid]").val(data.decidedzone_id); }else{ $("input[name=customerId]").val(""); $("input[name=customerName]").val(""); $("input[name=pickaddress]").val(""); $("input[name=delegater]").val(""); } }); }); }); </script> </head> <body class="easyui-layout" style="visibility:hidden;"> <div region="north" style="height:31px;overflow:hidden;" split="false" border="false"> <div class="datagrid-toolbar"> <a id="save" icon="icon-save" href="#" class="easyui-linkbutton" plain="true">新单</a> <a id="edit" icon="icon-edit" href="${pageContext.request.contextPath }/page_qupai_noticebill.action" class="easyui-linkbutton" plain="true">工单操作</a> </div> </div> <div region="center" style="overflow:auto;padding:5px;" border="false"> <form id="noticebillForm" action="${pageContext.request.contextPath}/noticeBillAction_save.action" method="post"> <table class="table-edit" width="95%" align="center"> <input type="hidden" name="decodeid"> //返回的json中decidedzone_id赋给隐藏框,给action使用,主要是用于根据id查询bc_decidedzone表中的staff_id <tr class="title"> <td colspan="4">客户信息</td> </tr> <tr> <td>来电号码:</td> <td><input type="text" class="easyui-validatebox" name="telephone" required="true" /></td> <td>客户编号:</td> <td><input type="text" class="easyui-validatebox" name="customerId" required="true" /></td> </tr> <tr> <td>客户姓名:</td> <td><input type="text" class="easyui-validatebox" name="customerName" required="true" /></td> <td>联系人:</td> <td><input type="text" class="easyui-validatebox" name="delegater" required="true" /></td> </tr> <tr class="title"> <td colspan="4">货物信息</td> </tr> <tr> <td>品名:</td> <td><input type="text" class="easyui-validatebox" name="product" required="true" /></td> <td>件数:</td> <td><input type="text" class="easyui-numberbox" name="num" required="true" /></td> </tr> <tr> <td>重量:</td> <td><input type="text" class="easyui-numberbox" name="weight" required="true" /></td> <td>体积:</td> <td><input type="text" class="easyui-validatebox" name="volume" required="true" /></td> </tr> <tr> <td>取件地址</td> <td colspan="3"><input type="text" class="easyui-validatebox" name="pickaddress" required="true" size="144"/></td> </tr> <tr> <td>到达城市:</td> <td><input type="text" class="easyui-validatebox" name="arrivecity" required="true" /></td> <td>预约取件时间:</td> <td><input type="text" class="easyui-datebox" name="pickdate" data-options="required:true, editable:false" /></td> </tr> <tr> <td>备注:</td> <td colspan="3"><textarea rows="5" cols="80" type="text" class="easyui-validatebox" name="remark" required="true" ></textarea></td> </tr> </table> </form> </div> </body> </html>
2、action
package com.dong.bos.web.action;
import com.dong.bos.model.Noticebill;
import com.dong.bos.service.INoticeBillService;
import com.dong.bos.utils.UserInfoUtils;
import com.dong.bos.web.action.base.BaseAction;
import com.gyf.crm.domain.Customer;
import org.apache.struts2.ServletActionContext;
import java.io.IOException;
import java.util.List;
public class NoticeBillAction extends BaseAction<Noticebill> {
private String tel;
public void setTel(String tel) { //获取电话
this.tel = tel;
}
public void findCustomerByTelephone() throws IOException { //根据电话查询crm系统数据,返回json
Customer customer = customerService.findCustomerByTel(tel);
RespJson(customer, new String[]{});
}
private String decodeid; //
public void setDecodeid(String decodeid) {
this.decodeid = decodeid;
}
@Override
public String save() {
iNoticeBillService.save(getModel(),decodeid);
return null;
}
@Override
public String update() {
return null;
}
@Override
public String delete() throws IOException {
return null;
}
@Override
public String list() {
return null;
}
}
3、service
public void save(Noticebill entity,String decidedzone_id) { entity.setOrdertype("新增"); entity.setUser(UserInfoUtils.UserInfo()); if(!StringUtils.isEmpty(decidedzone_id)){ Staff staff=iDecidedZoneDao.find(decidedzone_id).getStaff(); // 通过find方法得到DecidedZone对象,该对象 // 包括 id、name、staff,因此获取staff entity.setStaff(staff); } iNoticeBillDao.save(entity); }
4、映射
package com.dong.bos.model; import java.sql.Date; import java.util.Objects; public class Noticebill { private String id; private String customerId; private String customerName; private String delegater; private String telephone; private String pickaddress; private String arrivecity; private String product; private Date pickdate; private Integer num; private Double weight; private String volume; private String remark; private String ordertype; private Staff staff; private User user; public Staff getStaff() { return staff; } public void setStaff(Staff staff) { this.staff = staff; } public User getUser() { return user; } public void setUser(User user) { this.user = user; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getCustomerId() { return customerId; } public void setCustomerId(String customerId) { this.customerId = customerId; } public String getCustomerName() { return customerName; } public void setCustomerName(String customerName) { this.customerName = customerName; } public String getDelegater() { return delegater; } public void setDelegater(String delegater) { this.delegater = delegater; } public String getTelephone() { return telephone; } public void setTelephone(String telephone) { this.telephone = telephone; } public String getPickaddress() { return pickaddress; } public void setPickaddress(String pickaddress) { this.pickaddress = pickaddress; } public String getArrivecity() { return arrivecity; } public void setArrivecity(String arrivecity) { this.arrivecity = arrivecity; } public String getProduct() { return product; } public void setProduct(String product) { this.product = product; } public Date getPickdate() { return pickdate; } public void setPickdate(Date pickdate) { this.pickdate = pickdate; } public Integer getNum() { return num; } public void setNum(Integer num) { this.num = num; } public Double getWeight() { return weight; } public void setWeight(Double weight) { this.weight = weight; } public String getVolume() { return volume; } public void setVolume(String volume) { this.volume = volume; } public String getRemark() { return remark; } public void setRemark(String remark) { this.remark = remark; } public String getOrdertype() { return ordertype; } public void setOrdertype(String ordertype) { this.ordertype = ordertype; } @Override public String toString() { return "Noticebill{" + "id='" + id + '\'' + ", customerId='" + customerId + '\'' + ", customerName='" + customerName + '\'' + ", delegater='" + delegater + '\'' + ", telephone='" + telephone + '\'' + ", pickaddress='" + pickaddress + '\'' + ", arrivecity='" + arrivecity + '\'' + ", product='" + product + '\'' + ", pickdate=" + pickdate + ", num=" + num + ", weight=" + weight + ", volume='" + volume + '\'' + ", remark='" + remark + '\'' + ", ordertype='" + ordertype + '\'' + '}'; } }
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.dong.bos.model.Noticebill" table="qp_noticebill" schema="ssh">
<id name="id" column="id">
<generator class="uuid"></generator>
</id>
<property name="customerId" column="customer_id"/>
<property name="customerName" column="customer_name"/>
<property name="delegater" column="delegater"/>
<property name="telephone" column="telephone"/>
<property name="pickaddress" column="pickaddress"/>
<property name="arrivecity" column="arrivecity"/>
<property name="product" column="product"/>
<property name="pickdate" column="pickdate"/>
<property name="num" column="num"/>
<property name="weight" column="weight"/>
<property name="volume" column="volume"/>
<property name="remark" column="remark"/>
<property name="ordertype" column="ordertype"/>
<many-to-one name="user" class="com.dong.bos.model.User">
<column name="user_id" length="32" />
</many-to-one>
<!--员工-->
<many-to-one name="staff" class="com.dong.bos.model.Staff">
<column name="staff_id" length="32" />
</many-to-one>
</class>
</hibernate-mapping>