├── doc ├── 1.png ├── 2.png ├── 3.png ├── 4.png ├── 快递.xls ├── admin.png ├── query.png ├── contact.jpeg └── admin_detail.png ├── src └── main │ ├── resources │ ├── static │ │ ├── favicon.ico │ │ ├── css │ │ │ └── index.css │ │ ├── index1.html │ │ ├── index.html │ │ ├── js │ │ │ ├── index_back.js │ │ │ ├── index.js │ │ │ └── admin.js │ │ └── mht_search.html │ ├── application.properties │ ├── config │ │ └── mybatis-config.xml │ └── mapper │ │ └── KuaiDiMapper.xml │ └── java │ └── com │ └── wangzg │ └── kuaidi │ ├── domain │ ├── KuaidiInfo.java │ ├── Response.java │ ├── ResponseData.java │ └── KuaiDi.java │ ├── KuaiDiApplication.java │ ├── util │ ├── MessageEnum.java │ ├── PaginationResult.java │ ├── Message.java │ ├── MD5Utils.java │ ├── CommonUtils.java │ └── ExcelUtils.java │ ├── service │ ├── KuaiDiQueryService.java │ ├── KuaiDiService.java │ └── impl │ │ ├── KuaiDiServiceImpl.java │ │ └── KuaiDiQueryServiceImpl.java │ ├── mapper │ └── KuaiDiMapper.java │ └── web │ ├── KuaiDiController.java │ └── KuaiDiQueryController.java ├── .gitignore ├── Dockerfile ├── README.md └── pom.xml /doc/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellowHuaairen/kuaidi/HEAD/doc/1.png -------------------------------------------------------------------------------- /doc/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellowHuaairen/kuaidi/HEAD/doc/2.png -------------------------------------------------------------------------------- /doc/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellowHuaairen/kuaidi/HEAD/doc/3.png -------------------------------------------------------------------------------- /doc/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellowHuaairen/kuaidi/HEAD/doc/4.png -------------------------------------------------------------------------------- /doc/快递.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellowHuaairen/kuaidi/HEAD/doc/快递.xls -------------------------------------------------------------------------------- /doc/admin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellowHuaairen/kuaidi/HEAD/doc/admin.png -------------------------------------------------------------------------------- /doc/query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellowHuaairen/kuaidi/HEAD/doc/query.png -------------------------------------------------------------------------------- /doc/contact.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellowHuaairen/kuaidi/HEAD/doc/contact.jpeg -------------------------------------------------------------------------------- /doc/admin_detail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellowHuaairen/kuaidi/HEAD/doc/admin_detail.png -------------------------------------------------------------------------------- /src/main/resources/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellowHuaairen/kuaidi/HEAD/src/main/resources/static/favicon.ico -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | log/ 3 | 4 | application.yml 5 | 6 | ### IntelliJ IDEA ### 7 | .idea 8 | *.iws 9 | *.iml 10 | *.ipr 11 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hellowHuaairen/kuaidi/HEAD/src/main/resources/application.properties -------------------------------------------------------------------------------- /src/main/java/com/wangzg/kuaidi/domain/KuaidiInfo.java: -------------------------------------------------------------------------------- 1 | package com.wangzg.kuaidi.domain; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Created by wangzhiguo on 2019/8/29 0029. 7 | */ 8 | @Data 9 | public class KuaidiInfo { 10 | private String time; 11 | private String ftime; 12 | private String context; 13 | } 14 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | #基础配置 2 | FROM daocloud.io/library/java:8u40-b22 3 | VOLUME /tmp 4 | ARG JAR_FILE 5 | ADD ${JAR_FILE} /home/app.jar 6 | ADD src/main/resources/application.properties /home/conf/application.properties 7 | WORKDIR /home/ 8 | EXPOSE 8082 9 | ENTRYPOINT ["java","-jar","-Dspring.config.location=conf/application.properties","./app.jar"] 10 | -------------------------------------------------------------------------------- /src/main/java/com/wangzg/kuaidi/KuaiDiApplication.java: -------------------------------------------------------------------------------- 1 | package com.wangzg.kuaidi; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | 7 | @SpringBootApplication 8 | public class KuaiDiApplication { 9 | 10 | public static void main(String[] args) { 11 | SpringApplication.run(KuaiDiApplication.class, args); 12 | } 13 | } -------------------------------------------------------------------------------- /src/main/java/com/wangzg/kuaidi/domain/Response.java: -------------------------------------------------------------------------------- 1 | package com.wangzg.kuaidi.domain; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by wangzhiguo on 2019/8/29 0029. 9 | */ 10 | @Data 11 | public class Response { 12 | private String message = "ok"; 13 | private String state="0"; 14 | private String status ="200"; 15 | private List dataList; 16 | } 17 | -------------------------------------------------------------------------------- /src/main/resources/static/css/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: "Microsoft YaHei"; 3 | } 4 | 5 | nav a, .nav-li a { 6 | color: #f2f2f2 !important; 7 | } 8 | 9 | @media (min-width: 768px) { 10 | .nav-li:hover { 11 | background-color: black; 12 | font-size: 20px; 13 | } 14 | } 15 | 16 | nav { 17 | background-color: #424a57 !important; 18 | } 19 | 20 | .page-header { 21 | margin-top: 65px; 22 | } -------------------------------------------------------------------------------- /src/main/java/com/wangzg/kuaidi/domain/ResponseData.java: -------------------------------------------------------------------------------- 1 | package com.wangzg.kuaidi.domain; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by wangzhiguo on 2019/8/29 0029. 9 | */ 10 | @Data 11 | public class ResponseData { 12 | private String message; 13 | private String state; 14 | private String status; 15 | private String condition; 16 | private String ischeck; 17 | private String com; 18 | private String nu; 19 | private List data; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/resources/config/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/main/java/com/wangzg/kuaidi/util/MessageEnum.java: -------------------------------------------------------------------------------- 1 | package com.wangzg.kuaidi.util; 2 | 3 | /** 4 | * 存放消息代码及其类型描述 5 | */ 6 | public enum MessageEnum { 7 | SUCCESS(100, "success"), 8 | FAIL(200, "fail"); 9 | 10 | // 消息代码 11 | private Integer code; 12 | 13 | // 消息类型 14 | private String info; 15 | 16 | MessageEnum(Integer code, String info) { 17 | this.code = code; 18 | this.info = info; 19 | } 20 | 21 | public Integer getCode() { 22 | return code; 23 | } 24 | 25 | public String getInfo() { 26 | return info; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/wangzg/kuaidi/service/KuaiDiQueryService.java: -------------------------------------------------------------------------------- 1 | package com.wangzg.kuaidi.service; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * Created by wangzhiguo on 2019/8/28 0028. 7 | */ 8 | public interface KuaiDiQueryService { 9 | 10 | /** 11 | * 实时查询快递单号 12 | * @param com 快递公司编码 13 | * @param num 快递单号 14 | * @param phone 手机号 15 | * @param from 出发地城市 16 | * @param to 目的地城市 17 | * @param resultv2 开通区域解析功能:0-关闭;1-开通 18 | * @return 19 | */ 20 | String synQueryData(String com, String num, String phone, String from, String to, int resultv2); 21 | 22 | /** 23 | * 发送post请求 24 | */ 25 | String post(Map params); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/wangzg/kuaidi/mapper/KuaiDiMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangzg.kuaidi.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.wangzg.kuaidi.domain.KuaiDi; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.util.List; 10 | 11 | @Component 12 | @Mapper 13 | public interface KuaiDiMapper extends BaseMapper { 14 | 15 | // 查询 16 | List selectList(KuaiDi kuaiDi); 17 | 18 | // 新增 19 | // int insert(KuaiDi kuaiDi); 20 | 21 | // 修改 22 | int update(KuaiDi kuaiDi); 23 | 24 | // 删除 25 | int deleteById(@Param("id") Integer id); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/wangzg/kuaidi/service/KuaiDiService.java: -------------------------------------------------------------------------------- 1 | package com.wangzg.kuaidi.service; 2 | 3 | 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | import com.wangzg.kuaidi.domain.KuaiDi; 6 | import com.wangzg.kuaidi.util.Message; 7 | import org.springframework.web.multipart.MultipartFile; 8 | 9 | import java.util.List; 10 | 11 | public interface KuaiDiService extends IService { 12 | 13 | // 查询 14 | List getList(String username, String phone); 15 | 16 | // 新增 17 | Message add(String username, String phone, String kuaiDiNo, String company); 18 | 19 | // 修改 20 | Message modify(Integer id, String username, String phone, String kuaiDiNo, String company); 21 | 22 | // 删除 23 | Message removeById(Integer id); 24 | 25 | //导入文件内容 26 | void importData(MultipartFile multipartFile) throws Exception; 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/wangzg/kuaidi/util/PaginationResult.java: -------------------------------------------------------------------------------- 1 | package com.wangzg.kuaidi.util; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 用于返回分页结果 7 | */ 8 | public class PaginationResult { 9 | 10 | private long total; 11 | 12 | private List rows; 13 | 14 | public PaginationResult(long total, List rows) { 15 | this.total = total; 16 | this.rows = rows; 17 | } 18 | 19 | public long getTotal() { 20 | return total; 21 | } 22 | 23 | public void setTotal(long total) { 24 | this.total = total; 25 | } 26 | 27 | public List getRows() { 28 | return rows; 29 | } 30 | 31 | public void setRows(List rows) { 32 | this.rows = rows; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return "PaginationResult{" + 38 | "total=" + total + 39 | ", rows=" + rows + 40 | '}'; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/resources/mapper/KuaiDiMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 21 | 22 | 23 | INSERT INTO kuaidi(user_name, phone, kuaidi_no, company, create_time) 24 | VALUES (#{userName}, #{phone}, #{kuaidiNo}, #{company}, #{createTime}) 25 | 26 | 27 | 28 | UPDATE kuaidi 29 | SET user_name = #{userName}, phone = #{phone}, kuaidi_no = #{kuaidiNo}, company = #{company},create_time = #{createTime} 30 | WHERE id = #{id} 31 | 32 | 33 | 34 | DELETE 35 | FROM kuaidi 36 | WHERE id = #{id} 37 | 38 | -------------------------------------------------------------------------------- /src/main/java/com/wangzg/kuaidi/util/Message.java: -------------------------------------------------------------------------------- 1 | package com.wangzg.kuaidi.util; 2 | 3 | /** 4 | * 用于返回消息 5 | * @param 6 | */ 7 | public class Message { 8 | 9 | // 消息代码 10 | private Integer code; 11 | 12 | // 消息描述信息 13 | private String message; 14 | 15 | // 消息具体内容 16 | private T data; 17 | 18 | public Message() { 19 | } 20 | 21 | public Message(Integer code) { 22 | this.code = code; 23 | } 24 | 25 | public Message(Integer code, String message) { 26 | this.code = code; 27 | this.message = message; 28 | } 29 | 30 | public Message(Integer code, String message, T data) { 31 | this.code = code; 32 | this.message = message; 33 | this.data = data; 34 | } 35 | 36 | public Integer getCode() { 37 | return code; 38 | } 39 | 40 | public void setCode(Integer code) { 41 | this.code = code; 42 | } 43 | 44 | public String getMessage() { 45 | return message; 46 | } 47 | 48 | public void setMessage(String message) { 49 | this.message = message; 50 | } 51 | 52 | public T getData() { 53 | return data; 54 | } 55 | 56 | public void setData(T data) { 57 | this.data = data; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "Message{" + 63 | "code=" + code + 64 | ", message='" + message + '\'' + 65 | ", data=" + data + 66 | '}'; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/wangzg/kuaidi/util/MD5Utils.java: -------------------------------------------------------------------------------- 1 | package com.wangzg.kuaidi.util; 2 | 3 | import java.security.MessageDigest; 4 | import java.security.NoSuchAlgorithmException; 5 | 6 | /** 7 | * Created by wangzhiguo on 2019/8/28 0028. 8 | * md5加密 9 | */ 10 | 11 | public class MD5Utils { 12 | private static MessageDigest mdigest = null; 13 | private static char digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; 14 | 15 | private static MessageDigest getMdInst() { 16 | if (null == mdigest) { 17 | try { 18 | mdigest = MessageDigest.getInstance("MD5"); 19 | } catch (NoSuchAlgorithmException e) { 20 | e.printStackTrace(); 21 | } 22 | } 23 | return mdigest; 24 | } 25 | 26 | public static String encode(String s) { 27 | if(null == s) { 28 | return ""; 29 | } 30 | 31 | try { 32 | byte[] bytes = s.getBytes(); 33 | getMdInst().update(bytes); 34 | byte[] md = getMdInst().digest(); 35 | int j = md.length; 36 | char str[] = new char[j * 2]; 37 | int k = 0; 38 | for (int i = 0; i < j; i++) { 39 | byte byte0 = md[i]; 40 | str[k++] = digits[byte0 >>> 4 & 0xf]; 41 | str[k++] = digits[byte0 & 0xf]; 42 | } 43 | return new String(str); 44 | } catch (Exception e) { 45 | e.printStackTrace(); 46 | return null; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # 一、目的 3 | ## 现实中的痛点 4 | 现在周围的人都在做微商,如果每天订单量大的话,大量的时间会花费在给顾客快递单号的事情上。 5 | ## 解决问题 6 | 1. 我们在系统录入发货信息:收件人姓名,收件人电话,订单编号 7 | 2. 用户可电话号码查询自己的订单; 8 | 3. 点击订单编号,可跳转到快递详细物流信息页面。 9 | 10 | # 二、使用的技术 11 | 1. **SpringBoot** :Spring boot是Spring家族中的一个全新的框架,它用来简化Spring应用程序的创建和开发过程,也可以说Spring boot能简化我们之前采用SpringMVC+Spring+Mybatis框架进行开发的过程。 12 | 2. **Bootstrap-Table**:Bootstrap table是国人开发的一款基于 Bootstrap 的 jQuery 表格插件,通过简单的设置,就可以拥有强大的单选、多选、排序、分页,以及编辑、导出、过滤(扩展)等等的功能。 13 | 3. **Mysql**:MySQL是一个轻量级关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle公司。 MySQL是一个关系型数据库管理系统,MySQL是一种关联数据库管理系统,关联数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,就增加了速度并提高了灵活性。 14 | 4. **jQuery**:jQuery是一个开源免费的优秀JavaScript库,它能使用户更加方便地处理HTML文档、事件等等。jQuery由约翰·雷西格(John Resig)于2006年创建,从最初的增强CSS选择器功能,发展至今,功能超级丰富。 15 | # 三、操作步骤 16 | ## 1. 快递单号查询页面 17 | - 用户查询页面 18 | 19 | ![](./doc/query.png) 20 | 21 | - 管理员操作页面: 22 | 23 | ![](./doc/admin.png) 24 | 25 | 查看详细快递详细信息 26 | 27 | ![](./doc/admin_detail.png) 28 | 29 | 30 | 31 | ## 2. 点击快递单号,直接查看详情 32 | 33 | 方便用户的使用,直接点击订单编号,就可以跳转到快递的查询页面,支持所有快递订单的查询。 34 | 35 | 36 | 37 | 38 | # 四、持续更新 39 | 1. 快递信息批量导入功能; 40 | 2. 售后赔偿功能。 41 | 3. 自助下单服务,客户填写收货信息,下单信息存入后台系统。组织打包发货。(目前不考虑系统线上交易) 42 | 4. 快递后台管理系统: 43 | - 包括代理销量和收益信息统计 44 | - 个人效率和收益信息统计 45 | - 发货地区数量统计 46 | - 天/月/年总销量和收益信息统计 47 | - 人员管理 48 | # 五、项目部署文档 49 | 整理了一款简单的项目部署文档,参考地址:[项目部署文档](https://github.com/hellowHuaairen/kuaidi/wiki/%E5%BF%AB%E9%80%92%E6%9F%A5%E8%AF%A2%E9%A1%B9%E7%9B%AE%E9%83%A8%E7%BD%B2),接下来我会整理`Docker compose`的部署方案。 50 | 51 | # 六、联系我 52 | 53 | 分享是一种习惯,认识你才是我的真实目的! 54 | 55 | ![](./doc/contact.jpeg) 56 | -------------------------------------------------------------------------------- /src/main/java/com/wangzg/kuaidi/domain/KuaiDi.java: -------------------------------------------------------------------------------- 1 | package com.wangzg.kuaidi.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableField; 4 | import com.baomidou.mybatisplus.annotation.TableName; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | 8 | import java.util.Date; 9 | 10 | /** 11 | * 快递单号查询实体类 12 | */ 13 | @Data 14 | @Builder 15 | @TableName("kuaidi") 16 | public class KuaiDi { 17 | public KuaiDi(){} 18 | public KuaiDi(Integer id, String userName, String phone, String kuaidiNo, String company, Date createTime) { 19 | this.id = id; 20 | this.userName = userName; 21 | this.phone = phone; 22 | this.kuaidiNo = kuaidiNo; 23 | this.company = company; 24 | this.createTime = createTime; 25 | } 26 | public KuaiDi(Integer id, String userName, String phone, String kuaidiNo, String company) { 27 | this.id = id; 28 | this.userName = userName; 29 | this.phone = phone; 30 | this.kuaidiNo = kuaidiNo; 31 | this.company = company; 32 | } 33 | 34 | @TableField("ID") 35 | private Integer id; 36 | 37 | /** 38 | * 收件人姓名 39 | */ 40 | @TableField("USER_NAME") 41 | private String userName; 42 | /** 43 | * 收件人电话 44 | */ 45 | @TableField("PHONE") 46 | private String phone; 47 | 48 | /** 49 | * 快递单号 50 | */ 51 | @TableField("KUAIDI_NO") 52 | private String kuaidiNo; 53 | 54 | /** 55 | * 快递公司名称(拼音) 56 | */ 57 | @TableField("COMPANY") 58 | private String company; 59 | 60 | /** 61 | * 订单创建时间 62 | */ 63 | @TableField("CREATE_TIME") 64 | private Date createTime; 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/wangzg/kuaidi/util/CommonUtils.java: -------------------------------------------------------------------------------- 1 | package com.wangzg.kuaidi.util; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alibaba.fastjson.TypeReference; 5 | import com.wangzg.kuaidi.domain.ResponseData; 6 | import org.apache.commons.lang3.StringUtils; 7 | 8 | /** 9 | * Created by wangzhiguo on 2019/8/29 0029. 10 | */ 11 | public class CommonUtils { 12 | 13 | /** 14 | * 将json字符串转化为对象 15 | * @param jsonStr 16 | * @return 17 | */ 18 | public static ResponseData convertJsonStr2Object(String jsonStr){ 19 | ResponseData responseData = new ResponseData(); 20 | if(StringUtils.isNotEmpty(jsonStr)){ 21 | responseData = JSON.parseObject(jsonStr, new TypeReference(){}); 22 | } 23 | return responseData; 24 | } 25 | 26 | public static void main(String[] args) { 27 | String jsonStr = "{\n" + 28 | " \"message\":\"ok\",\n" + 29 | " \"state\":\"0\",\n" + 30 | " \"status\":\"200\",\n" + 31 | " \"condition\":\"F00\",\n" + 32 | " \"ischeck\":\"0\",\n" + 33 | " \"com\":\"yuantong\",\n" + 34 | " \"nu\":\"V030344422\",\n" + 35 | " \"data\":[\n" + 36 | " {\n" + 37 | " \"context\":\"上海分拨中心/装件入车扫描 \",\n" + 38 | " \"time\":\"2012-08-28 16:33:19\",\n" + 39 | " \"ftime\":\"2012-08-28 16:33:19\",\n" + 40 | " },\n" + 41 | " {\n" + 42 | " \"context\":\"上海分拨中心/下车扫描 \",\n" + 43 | " \"time\":\"2012-08-27 23:22:42\",\n" + 44 | " \"ftime\":\"2012-08-27 23:22:42\",\n" + 45 | " }]\n" + 46 | "}"; 47 | 48 | System.out.println(CommonUtils.convertJsonStr2Object(jsonStr)); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/wangzg/kuaidi/web/KuaiDiController.java: -------------------------------------------------------------------------------- 1 | package com.wangzg.kuaidi.web; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.github.pagehelper.PageHelper; 5 | import com.wangzg.kuaidi.domain.KuaiDi; 6 | import com.wangzg.kuaidi.service.KuaiDiService; 7 | import com.wangzg.kuaidi.util.Message; 8 | import com.wangzg.kuaidi.util.PaginationResult; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.PostMapping; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.ResponseBody; 13 | import org.springframework.web.bind.annotation.RestController; 14 | import org.springframework.web.multipart.MultipartFile; 15 | 16 | import java.util.List; 17 | 18 | 19 | @RestController 20 | public class KuaiDiController { 21 | 22 | @Autowired 23 | private KuaiDiService kuaiDiService; 24 | 25 | 26 | @RequestMapping("/getList") 27 | public @ResponseBody 28 | PaginationResult getList(int offset, int limit, String userName, String phone) { 29 | Page page = PageHelper.offsetPage(offset, limit); 30 | List kuaiDiList = kuaiDiService.getList(userName, phone); 31 | return new PaginationResult(page.getTotal(), kuaiDiList); 32 | } 33 | 34 | @PostMapping("/addKuaiDi") 35 | public @ResponseBody 36 | Message addKuaiDi(String userName, String phone, String kuaiDiNo, String company) { 37 | return kuaiDiService.add(userName, phone, kuaiDiNo, company); 38 | } 39 | 40 | @PostMapping("/delKuaiDi") 41 | public @ResponseBody 42 | Message delKuaiDi(Integer id) { 43 | return kuaiDiService.removeById(id); 44 | } 45 | 46 | @PostMapping("/modifyKuaiDi") 47 | public @ResponseBody 48 | Message modifyKuaiDi(Integer id, String userName, String phone, String kuaiDiNo, String company) { 49 | return kuaiDiService.modify(id, userName, phone, kuaiDiNo, company); 50 | } 51 | 52 | @PostMapping("/import") 53 | public Message importData(MultipartFile multipartFile) throws Exception{ 54 | kuaiDiService.importData(multipartFile); 55 | return new Message(200); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/wangzg/kuaidi/util/ExcelUtils.java: -------------------------------------------------------------------------------- 1 | package com.wangzg.kuaidi.util; 2 | 3 | import cn.hutool.core.bean.BeanUtil; 4 | import cn.hutool.core.collection.CollectionUtil; 5 | import cn.hutool.core.io.FileUtil; 6 | import cn.hutool.core.io.resource.ResourceUtil; 7 | import cn.hutool.core.map.MapUtil; 8 | import cn.hutool.poi.excel.ExcelReader; 9 | import cn.hutool.poi.excel.ExcelUtil; 10 | import com.wangzg.kuaidi.domain.KuaiDi; 11 | import org.apache.commons.beanutils.BeanUtils; 12 | 13 | import java.io.InputStream; 14 | import java.io.InputStreamReader; 15 | import java.lang.reflect.InvocationTargetException; 16 | import java.util.*; 17 | 18 | import static org.apache.commons.beanutils.BeanUtils.populate; 19 | 20 | /** 21 | * @author wangzg 22 | * @date 2020/4/13 23 | */ 24 | public class ExcelUtils { 25 | 26 | /** 27 | * 获取第一个sheet页的内容 28 | * @param inputStream 29 | * @return 30 | */ 31 | public static List getKuaiDiList(InputStream inputStream) { 32 | List kuaiDiList = new ArrayList<>(); 33 | if(Objects.nonNull(inputStream)){ 34 | ExcelReader excelReader = ExcelUtil.getReader(inputStream); 35 | excelReader.addHeaderAlias("快递单号","kuaidiNo"); 36 | excelReader.addHeaderAlias("用户名","userName"); 37 | excelReader.addHeaderAlias("电话","phone"); 38 | excelReader.addHeaderAlias("快递公司","company"); 39 | List> rowList = excelReader.readAll(); 40 | if(CollectionUtil.isNotEmpty(rowList)){ 41 | rowList.stream().forEach(r->{ 42 | KuaiDi kuaiDi = new KuaiDi(); 43 | try { 44 | populate(kuaiDi,r); 45 | kuaiDi.setCreateTime(new Date()); 46 | kuaiDiList.add(kuaiDi); 47 | } catch (Exception e) { 48 | e.printStackTrace(); 49 | } 50 | }); 51 | } 52 | } 53 | return kuaiDiList; 54 | } 55 | 56 | public static void main(String[] args) { 57 | List kuaiDiList = getKuaiDiList(ResourceUtil.getStream("D:\\快递.xls")); 58 | kuaiDiList.stream().forEach(System.out::println); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/wangzg/kuaidi/web/KuaiDiQueryController.java: -------------------------------------------------------------------------------- 1 | package com.wangzg.kuaidi.web; 2 | 3 | 4 | 5 | import com.wangzg.kuaidi.domain.KuaiDi; 6 | import com.wangzg.kuaidi.domain.Response; 7 | import com.wangzg.kuaidi.domain.ResponseData; 8 | import com.wangzg.kuaidi.service.KuaiDiQueryService; 9 | import com.wangzg.kuaidi.service.KuaiDiService; 10 | import com.wangzg.kuaidi.util.CommonUtils; 11 | import org.apache.commons.lang3.StringUtils; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Controller; 14 | import org.springframework.ui.Model; 15 | import org.springframework.util.CollectionUtils; 16 | import org.springframework.web.bind.annotation.*; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | 22 | @RestController 23 | public class KuaiDiQueryController { 24 | 25 | @Autowired 26 | private KuaiDiService kuaiDiService; 27 | @Autowired 28 | private KuaiDiQueryService kuaiDiQueryService; 29 | 30 | /** 31 | * 返回json数据 32 | * @param com 33 | * @param no 34 | * @return 35 | */ 36 | @GetMapping("/getKuaiDiInfoByJson") 37 | @ResponseBody 38 | public String queryKuadiInfoByJson(String com, String no) { 39 | return kuaiDiQueryService.synQueryData(com, no,"", "", "", 0); 40 | } 41 | 42 | @GetMapping("/getKuaiDiInfoByPhone") 43 | @ResponseBody 44 | public Response queryKuaidiByPhone(String phone){ 45 | Response response = new Response(); 46 | if(StringUtils.isNotEmpty(phone)){ 47 | List responseDataList = new ArrayList<>(); 48 | // 1.通过手机号查询下面的所有订单号 49 | List kuaiDiList = kuaiDiService.getList("", phone); 50 | if(!CollectionUtils.isEmpty(kuaiDiList)){ 51 | kuaiDiList.forEach(kuaiDi -> { 52 | // 2.依次查出所有的订单号 53 | String responseDataStr = kuaiDiQueryService.synQueryData(kuaiDi.getCompany(), kuaiDi.getKuaidiNo(),"", "", "", 0); 54 | ResponseData responseData = CommonUtils.convertJsonStr2Object(responseDataStr); 55 | responseDataList.add(responseData); 56 | }); 57 | } 58 | // 3.组装数据返回给前台 59 | response.setDataList(responseDataList); 60 | } 61 | return response; 62 | } 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/wangzg/kuaidi/service/impl/KuaiDiServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangzg.kuaidi.service.impl; 2 | 3 | import cn.hutool.core.collection.CollectionUtil; 4 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 5 | import com.wangzg.kuaidi.domain.KuaiDi; 6 | import com.wangzg.kuaidi.mapper.KuaiDiMapper; 7 | import com.wangzg.kuaidi.service.KuaiDiService; 8 | import com.wangzg.kuaidi.util.ExcelUtils; 9 | import com.wangzg.kuaidi.util.Message; 10 | import com.wangzg.kuaidi.util.MessageEnum; 11 | import org.apache.commons.lang3.StringUtils; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Service; 14 | import org.springframework.web.multipart.MultipartFile; 15 | 16 | import java.util.Date; 17 | import java.util.List; 18 | 19 | @Service 20 | public class KuaiDiServiceImpl extends ServiceImpl implements KuaiDiService { 21 | 22 | // private final Logger log = LoggerFactory.getLogger(this.getClass()); 23 | 24 | @Autowired 25 | private KuaiDiMapper kuaiDiMapper; 26 | 27 | 28 | @Override 29 | public List getList(String username, String phone) { 30 | 31 | username = StringUtils.defaultString(username); 32 | phone = StringUtils.defaultString(phone); 33 | 34 | KuaiDi kuaiDi = KuaiDi.builder() 35 | .userName(username.trim()).phone(phone.trim()).build(); 36 | return kuaiDiMapper.selectList(kuaiDi); 37 | } 38 | 39 | @Override 40 | public Message add(String username, String phone, String kuaiDiNo, String company) { 41 | 42 | Message msg; 43 | 44 | KuaiDi kuaiDi = buildKuaiDiObject(username, phone, kuaiDiNo, company); 45 | int rowCount = kuaiDiMapper.insert(kuaiDi); 46 | if (rowCount == 0) { 47 | msg = new Message(MessageEnum.FAIL.getCode(), "新增失败!"); 48 | } else { 49 | msg = new Message(MessageEnum.SUCCESS.getCode(), "新增成功!"); 50 | } 51 | return msg; 52 | } 53 | 54 | /** 55 | * 构建KuaiDi对象 56 | * @param username 57 | * @param phone 58 | * @param kuaiDiNo 59 | * @param company 60 | * @return 61 | */ 62 | private KuaiDi buildKuaiDiObject(String username, String phone, String kuaiDiNo, String company){ 63 | username = StringUtils.defaultString(username); 64 | phone = StringUtils.defaultString(phone); 65 | kuaiDiNo = StringUtils.defaultString(kuaiDiNo); 66 | company = StringUtils.defaultString(company); 67 | KuaiDi kuaiDi = KuaiDi.builder() 68 | .userName(username.trim()).phone(phone.trim()) 69 | .kuaidiNo(kuaiDiNo).company(company).createTime(new Date()).build(); 70 | 71 | return kuaiDi; 72 | 73 | } 74 | @Override 75 | public Message modify(Integer id, String username, String phone, String kuaiDiNo, String company) { 76 | 77 | Message msg; 78 | 79 | KuaiDi kuaiDi = buildKuaiDiObject(username, phone, kuaiDiNo, company); 80 | kuaiDi.setId(id); 81 | 82 | int rowCount = kuaiDiMapper.update(kuaiDi); 83 | if (rowCount == 0) { 84 | msg = new Message(MessageEnum.FAIL.getCode(), "修改失败!"); 85 | } else { 86 | msg = new Message(MessageEnum.SUCCESS.getCode(), "修改成功!"); 87 | } 88 | 89 | return msg; 90 | } 91 | 92 | @Override 93 | public Message removeById(Integer id) { 94 | Message msg; 95 | int rowCount = kuaiDiMapper.deleteById(id); 96 | if (rowCount == 0) { 97 | msg = new Message(MessageEnum.FAIL.getCode(), "删除失败!"); 98 | }else { 99 | msg = new Message(MessageEnum.SUCCESS.getCode(), "删除成功!"); 100 | } 101 | return msg; 102 | } 103 | 104 | @Override 105 | public void importData(MultipartFile multipartFile) throws Exception{ 106 | List kuaiDiList = ExcelUtils.getKuaiDiList(multipartFile.getInputStream()); 107 | if(CollectionUtil.isNotEmpty(kuaiDiList)){ 108 | //批量插入 109 | this.saveBatch(kuaiDiList); 110 | } 111 | } 112 | 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/com/wangzg/kuaidi/service/impl/KuaiDiQueryServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangzg.kuaidi.service.impl; 2 | import com.wangzg.kuaidi.service.KuaiDiQueryService; 3 | import com.wangzg.kuaidi.util.MD5Utils; 4 | import org.springframework.stereotype.Service; 5 | 6 | import java.io.BufferedReader; 7 | import java.io.IOException; 8 | import java.io.InputStreamReader; 9 | import java.net.HttpURLConnection; 10 | import java.net.URL; 11 | import java.net.URLEncoder; 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | 15 | 16 | /** 17 | * 实时查询请求Demo 18 | * @author Administrator 19 | * 20 | */ 21 | @Service 22 | public class KuaiDiQueryServiceImpl implements KuaiDiQueryService { 23 | 24 | public static void main(String[] args) { 25 | String key = "hkjeyxNE1250"; //贵司的授权key 26 | String customer = "545F71CBAF8B28420DED50BC37BC2822"; //贵司的查询公司编号 27 | String com = "yunda"; //快递公司编码 28 | String num = "4300495437386"; //快递单号 29 | String phone = ""; //手机号码后四位 30 | String from = ""; //出发地 31 | String to = ""; //目的地 32 | int resultv2 = 0; //开启行政规划解析 33 | 34 | KuaiDiQueryServiceImpl kuaiDiQueryService = new KuaiDiQueryServiceImpl(); 35 | String result = kuaiDiQueryService.synQueryData(com, num, phone, from, to, resultv2); 36 | System.out.println(result); 37 | } 38 | 39 | /** 40 | * 实时查询请求地址 41 | */ 42 | private static final String SYNQUERY_URL = "http://poll.kuaidi100.com/poll/query.do"; 43 | 44 | private String key = "hkjeyxNE1250"; //授权key 45 | private String customer= "545F71CBAF8B28420DED50BC37BC2822"; //实时查询公司编号 46 | 47 | 48 | @Override 49 | public String synQueryData(String com, String num, String phone, String from, String to, int resultv2) { 50 | 51 | StringBuilder param = new StringBuilder("{"); 52 | param.append("\"com\":\"").append(com).append("\""); 53 | param.append(",\"num\":\"").append(num).append("\""); 54 | param.append(",\"phone\":\"").append(phone).append("\""); 55 | param.append(",\"from\":\"").append(from).append("\""); 56 | param.append(",\"to\":\"").append(to).append("\""); 57 | if(1 == resultv2) { 58 | param.append(",\"resultv2\":1"); 59 | } else { 60 | param.append(",\"resultv2\":0"); 61 | } 62 | param.append("}"); 63 | 64 | Map params = new HashMap(); 65 | params.put("customer", this.customer); 66 | String sign = MD5Utils.encode(param + this.key + this.customer); 67 | params.put("sign", sign); 68 | params.put("param", param.toString()); 69 | 70 | return this.post(params); 71 | } 72 | 73 | 74 | @Override 75 | public String post(Map params) { 76 | StringBuffer response = new StringBuffer(""); 77 | 78 | BufferedReader reader = null; 79 | try { 80 | StringBuilder builder = new StringBuilder(); 81 | for (Map.Entry param : params.entrySet()) { 82 | if (builder.length() > 0) { 83 | builder.append('&'); 84 | } 85 | builder.append(URLEncoder.encode(param.getKey(), "UTF-8")); 86 | builder.append('='); 87 | builder.append(URLEncoder.encode(String.valueOf(param.getValue()), "UTF-8")); 88 | } 89 | byte[] bytes = builder.toString().getBytes("UTF-8"); 90 | 91 | URL url = new URL(SYNQUERY_URL); 92 | HttpURLConnection conn = (HttpURLConnection) url.openConnection(); 93 | conn.setConnectTimeout(3000); 94 | conn.setReadTimeout(3000); 95 | conn.setRequestMethod("POST"); 96 | conn.setRequestProperty("accept", "*/*"); 97 | conn.setRequestProperty("connection", "Keep-Alive"); 98 | conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); 99 | conn.setRequestProperty("Content-Length", String.valueOf(bytes.length)); 100 | conn.setDoOutput(true); 101 | conn.getOutputStream().write(bytes); 102 | 103 | reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8")); 104 | 105 | String line = ""; 106 | while ((line = reader.readLine()) != null) { 107 | response.append(line); 108 | } 109 | } catch (Exception e) { 110 | e.printStackTrace(); 111 | } finally { 112 | try { 113 | if (null != reader) { 114 | reader.close(); 115 | } 116 | } catch (IOException e) { 117 | e.printStackTrace(); 118 | } 119 | } 120 | 121 | return response.toString(); 122 | } 123 | } 124 | 125 | -------------------------------------------------------------------------------- /src/main/resources/static/index1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 快递单号查询 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 45 |
46 | 47 |

48 | 快递单号自助查询 49 |

50 | 51 | 52 |
53 |
54 | 55 | 56 |
57 |
58 | 59 | 60 |
61 | 62 |
63 |
64 | 65 |
66 |
    67 |
68 |
69 | 70 |
71 | 72 | 123 | 124 | -------------------------------------------------------------------------------- /src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 快递单号查询 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 45 |
46 | 47 |

48 | 快递单号自助查询 49 |

50 | 51 | 52 |
53 | 57 |
58 | 59 | 60 |
61 | 62 |
63 |
64 | 65 |
66 | 67 |
68 | 69 | 136 | 137 | -------------------------------------------------------------------------------- /src/main/resources/static/js/index_back.js: -------------------------------------------------------------------------------- 1 | var $testTable = $('#testTable'); 2 | $testTable.bootstrapTable({ 3 | url: 'getPers', 4 | queryParams: function (params) { 5 | return { 6 | offset: params.offset, 7 | limit: params.limit, 8 | name: $('#queryNameText').val(), 9 | age: $('#queryAgeText').val() 10 | } 11 | }, 12 | columns: [{ 13 | field: 'id', 14 | title: '编号' 15 | }, { 16 | field: 'name', 17 | title: '姓名' 18 | }, { 19 | field: 'age', 20 | title: '年龄' 21 | }, { 22 | field: 'address', 23 | title: '地址' 24 | }, { 25 | formatter: function (value, row, index) { 26 | return [ 27 | '' + 28 | '修改' + 29 | '', 30 | '' + 31 | '删除' + 32 | '' 33 | ].join(''); 34 | }, 35 | title: '操作' 36 | }], 37 | striped: true, 38 | pagination: true, 39 | sidePagination: 'server', 40 | pageSize: 10, 41 | pageList: [5, 10, 25, 50, 100], 42 | rowStyle: function (row, index) { 43 | var ageClass = ''; 44 | if (row.age < 18) { 45 | ageClass = 'text-danger'; 46 | } 47 | return {classes: ageClass} 48 | }, 49 | }); 50 | 51 | // 设置bootbox中文 52 | bootbox.setLocale('zh_CN'); 53 | 54 | var titleTip = '提示'; 55 | 56 | // 验证输入的年龄是否为数字 57 | function verifyAge(age) { 58 | var reg = /^[0-9]{0,3}$/; 59 | if (!reg.test(age)) { 60 | return false; 61 | } 62 | return true; 63 | } 64 | 65 | // 验证姓名和地址是否为空 66 | function verifyNameAndAddress(name, address) { 67 | if (name != '' && address != '') { 68 | return true; 69 | } 70 | return false; 71 | } 72 | 73 | function nullAlert() { 74 | bootbox.alert({ 75 | title: titleTip, 76 | message: '所有项均为必填!' 77 | }); 78 | } 79 | 80 | // 点击查询按钮,年龄符合查询条件方可跳转查询 81 | $('#queryBtn').click(function () { 82 | var age = $('#queryAgeText').val(); 83 | if (verifyAge(age)) { 84 | // 刷新并跳转到第一页 85 | $testTable.bootstrapTable('selectPage', 1); 86 | } else { 87 | bootbox.alert({ 88 | title: titleTip, 89 | message: '年龄输入有误!' 90 | }); 91 | } 92 | }); 93 | 94 | // 点击重置按钮,清空查询条件并跳转回第一页 95 | $('#resetBtn').click(function() { 96 | $('.form-group :text').val(''); 97 | $testTable.bootstrapTable('selectPage', 1); 98 | }); 99 | 100 | // 用于修改服务器资源 101 | function exchangeData(path, id, name, age, address) { 102 | $.ajax({ 103 | url: path, 104 | type: 'post', 105 | data : { 106 | id: id, 107 | name: name, 108 | age: age, 109 | address: address 110 | }, 111 | success: function(res) { 112 | bootbox.alert({ 113 | title: titleTip, 114 | message: res.message 115 | }); 116 | // 在每次提交操作后返回首页 117 | $testTable.bootstrapTable('selectPage', 1); 118 | } 119 | }); 120 | } 121 | 122 | // 新增 123 | $('#addBtn').click(function() { 124 | $('#addNameText').val(''); 125 | $('#addAgeText').val(''); 126 | $('#addAddressText').val(''); 127 | $('#addModal').modal('show'); 128 | }); 129 | 130 | $('#saveAdd').click(function() { 131 | $('#addModal').modal('hide'); 132 | bootbox.confirm({ 133 | title: titleTip, 134 | message: '确认增加?', 135 | callback: function (flag) { 136 | if (flag) { 137 | var name = $('#addNameText').val(); 138 | var age = $('#addAgeText').val(); 139 | var address = $('#addAddressText').val(); 140 | if (verifyNameAndAddress(name, address)) { 141 | exchangeData('addPer', null, name, age, address); 142 | } else { 143 | nullAlert(); 144 | } 145 | } 146 | } 147 | }); 148 | }); 149 | 150 | var mid; 151 | 152 | // 修改 153 | function modifyPer(id, name, age, address) { 154 | mid = id; 155 | $('#modifyNameText').val(name); 156 | $('#modifyAgeText').val(age); 157 | $('#modifyAddressText').val(address); 158 | $('#modifyModal').modal('show'); 159 | } 160 | 161 | $('#saveModify').click(function() { 162 | $('#modifyModal').modal('hide'); 163 | bootbox.confirm({ 164 | title: titleTip, 165 | message: '确认修改?', 166 | callback: function (flag) { 167 | if (flag) { 168 | var name = $('#modifyNameText').val(); 169 | var age = $('#modifyAgeText').val(); 170 | var address = $('#modifyAddressText').val(); 171 | if (verifyNameAndAddress(name, address)) { 172 | exchangeData('modifyPer', mid, name, age, address); 173 | } else { 174 | nullAlert(); 175 | } 176 | } 177 | } 178 | }); 179 | }); 180 | 181 | // 删除 182 | function delPer(id) { 183 | bootbox.confirm({ 184 | title: titleTip, 185 | message: '确认删除?', 186 | callback: function(flag) { 187 | if (flag) { 188 | exchangeData("delPer", id); 189 | } 190 | } 191 | }); 192 | } -------------------------------------------------------------------------------- /src/main/resources/static/js/index.js: -------------------------------------------------------------------------------- 1 | var $testTable = $('#testTable'); 2 | $testTable.bootstrapTable({ 3 | url: 'getList', 4 | queryParams: function (params) { 5 | return { 6 | offset: params.offset, 7 | limit: params.limit, 8 | userName: $('#queryNameText').val(), 9 | phone: $('#queryPhoneText').val() 10 | } 11 | }, 12 | columns: [{ 13 | field: 'id', 14 | title: '编号' 15 | }, { 16 | field: 'userName', 17 | title: '收件人姓名' 18 | }, { 19 | field: 'phone', 20 | title: '收件人电话' 21 | }, { 22 | field: 'kuaidiNo', 23 | title: '快递单号', 24 | formatter: function (value, row, index) { 25 | return [ 26 | ''+ row.kuaidiNo + '' 27 | ].join(''); 28 | }, 29 | } 30 | // , 31 | // { 32 | // formatter: function (value, row, index) { 33 | // return [ 34 | // '' + 35 | // '修改' + 36 | // '', 37 | // '' + 38 | // '删除' + 39 | // '' 40 | // ].join(''); 41 | // }, 42 | // title: '操作' 43 | // } 44 | ], 45 | striped: true, 46 | pagination: true, 47 | sidePagination: 'server', 48 | pageSize: 10, 49 | pageList: [5, 10, 25, 50, 100], 50 | rowStyle: function (row, index) { 51 | var ageClass = ''; 52 | if (row.age < 18) { 53 | ageClass = 'text-danger'; 54 | } 55 | return {classes: ageClass} 56 | }, 57 | }); 58 | 59 | // 设置bootbox中文 60 | bootbox.setLocale('zh_CN'); 61 | 62 | var titleTip = '提示'; 63 | 64 | // 验证输入的年龄是否为数字 65 | function verifyAge(age) { 66 | var reg = /^[0-9]{0,3}$/; 67 | if (!reg.test(age)) { 68 | return false; 69 | } 70 | return true; 71 | } 72 | 73 | // 验证姓名和地址是否为空 74 | function verifyNameAndAddress(name, address) { 75 | if (name != '' && address != '') { 76 | return true; 77 | } 78 | return false; 79 | } 80 | 81 | function nullAlert() { 82 | bootbox.alert({ 83 | title: titleTip, 84 | message: '所有项均为必填!' 85 | }); 86 | } 87 | 88 | // 点击查询按钮,年龄符合查询条件方可跳转查询 89 | $('#queryBtn').click(function () { 90 | // var age = $('#queryAgeText').val(); 91 | // if (verifyAge(age)) { 92 | // 刷新并跳转到第一页 93 | $testTable.bootstrapTable('selectPage', 1); 94 | // } else { 95 | // bootbox.alert({ 96 | // title: titleTip, 97 | // message: '年龄输入有误!' 98 | // }); 99 | // } 100 | }); 101 | 102 | // 点击重置按钮,清空查询条件并跳转回第一页 103 | $('#resetBtn').click(function() { 104 | $('.form-group :text').val(''); 105 | $testTable.bootstrapTable('selectPage', 1); 106 | }); 107 | 108 | // 用于修改服务器资源 109 | function exchangeData(path, id, userName, phone, kuaiDiNo) { 110 | $.ajax({ 111 | url: path, 112 | type: 'post', 113 | data : { 114 | id: id, 115 | userName: userName, 116 | phone: phone, 117 | kuaiDiNo: kuaiDiNo 118 | }, 119 | success: function(res) { 120 | bootbox.alert({ 121 | title: titleTip, 122 | message: res.message 123 | }); 124 | // 在每次提交操作后返回首页 125 | $testTable.bootstrapTable('selectPage', 1); 126 | } 127 | }); 128 | } 129 | 130 | // 新增 131 | $('#addBtn').click(function() { 132 | $('#addNameText').val(''); 133 | $('#addPhoneText').val(''); 134 | $('#addKuaiDiNoText').val(''); 135 | $('#addModal').modal('show'); 136 | }); 137 | 138 | $('#saveAdd').click(function() { 139 | $('#addModal').modal('hide'); 140 | bootbox.confirm({ 141 | title: titleTip, 142 | message: '确认增加?', 143 | callback: function (flag) { 144 | if (flag) { 145 | var userName = $('#addNameText').val(); 146 | var phone = $('#addPhoneText').val(); 147 | var kuaiDiNo = $('#addKuaiDiNoText').val(); 148 | if (verifyNameAndAddress(userName, kuaiDiNo)) { 149 | exchangeData('addKuaiDi', null, userName, phone, kuaiDiNo); 150 | } else { 151 | nullAlert(); 152 | } 153 | } 154 | } 155 | }); 156 | }); 157 | 158 | var mid; 159 | 160 | // 修改 161 | function modifyKuaiDi(id, name, age, address) { 162 | mid = id; 163 | $('#modifyNameText').val(name); 164 | $('#modifyPhoneText').val(age); 165 | $('#modifyKuaiDiNoText').val(address); 166 | $('#modifyModal').modal('show'); 167 | } 168 | 169 | $('#saveModify').click(function() { 170 | $('#modifyModal').modal('hide'); 171 | bootbox.confirm({ 172 | title: titleTip, 173 | message: '确认修改?', 174 | callback: function (flag) { 175 | if (flag) { 176 | var userName = $('#modifyNameText').val(); 177 | var phone = $('#modifyPhoneText').val(); 178 | var kuaiDiNo = $('#modifyKuaiDiNoText').val(); 179 | if (verifyNameAndAddress(userName, phone)) { 180 | exchangeData('modifyKuaiDi', mid, userName, phone, kuaiDiNo); 181 | } else { 182 | nullAlert(); 183 | } 184 | } 185 | } 186 | }); 187 | }); 188 | 189 | // 删除 190 | function delKuaiDi(id) { 191 | bootbox.confirm({ 192 | title: titleTip, 193 | message: '确认删除?', 194 | callback: function(flag) { 195 | if (flag) { 196 | exchangeData("delKuaiDi", id); 197 | } 198 | } 199 | }); 200 | } -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.wangzg 7 | kuaidi 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | kuaidi 12 | bootstrap table by springBoot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.5.4.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | kuaidi 26 | kuaidi 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter 33 | 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-test 38 | test 39 | 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-starter-aop 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | org.springframework.boot 54 | spring-boot-starter-web 55 | 56 | 62 | 63 | 64 | 70 | 71 | org.springframework.boot 72 | spring-boot-starter-actuator 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | mysql 90 | mysql-connector-java 91 | 92 | 93 | 94 | 95 | com.alibaba 96 | druid 97 | 1.0.29 98 | 99 | 100 | 101 | 102 | com.github.pagehelper 103 | pagehelper-spring-boot-starter 104 | 1.1.1 105 | 106 | 107 | org.projectlombok 108 | lombok 109 | 1.18.4 110 | 111 | 112 | org.apache.commons 113 | commons-lang3 114 | 3.8.1 115 | 116 | 117 | 118 | 119 | com.alibaba 120 | fastjson 121 | 1.2.17 122 | 123 | 124 | 125 | 126 | cn.hutool 127 | hutool-all 128 | 5.3.0 129 | 130 | 131 | org.apache.poi 132 | poi-ooxml 133 | 4.1.2 134 | 135 | 136 | xerces 137 | xercesImpl 138 | 2.12.0 139 | 140 | 141 | 142 | 143 | com.baomidou 144 | mybatis-plus-boot-starter 145 | 3.0.6 146 | 147 | 148 | 149 | 150 | commons-beanutils 151 | commons-beanutils 152 | 1.9.3 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | org.springframework.boot 162 | spring-boot-maven-plugin 163 | 164 | 165 | 166 | com.spotify 167 | dockerfile-maven-plugin 168 | 1.4.6 169 | 170 | ${docker.image.prefix}/${project.artifactId} 171 | ${project.basedir} 172 | ${project.version} 173 | ${docker.images.repository}/${project.artifactId} 174 | 175 | target/${project.build.finalName}.jar 176 | 177 | 178 | 179 | / 180 | ${project.build.directory} 181 | ${project.build.finalName}.jar 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | -------------------------------------------------------------------------------- /src/main/resources/static/js/admin.js: -------------------------------------------------------------------------------- 1 | var $testTable = $('#testTable'); 2 | $testTable.bootstrapTable({ 3 | url: 'getList', 4 | queryParams: function (params) { 5 | return { 6 | offset: params.offset, 7 | limit: params.limit, 8 | userName: $('#queryNameText').val(), 9 | phone: $('#queryPhoneText').val() 10 | } 11 | }, 12 | columns: [{ 13 | field: 'id', 14 | title: '编号' 15 | }, { 16 | field: 'userName', 17 | title: '收件人姓名' 18 | }, { 19 | field: 'phone', 20 | title: '收件人电话' 21 | }, { 22 | field: 'company', 23 | title: '快递公司' 24 | },{ 25 | field: 'kuaidiNo', 26 | title: '快递单号', 27 | formatter: function (value, row, index) { 28 | return [ 29 | '' + row.kuaidiNo +'', 30 | ].join(''); 31 | }, 32 | }, { 33 | formatter: function (value, row, index) { 34 | return [ 35 | '' + 36 | '修改' + 37 | '', 38 | '' + 39 | '删除' + 40 | '' 41 | ].join(''); 42 | }, 43 | title: '操作' 44 | }], 45 | striped: true, 46 | pagination: true, 47 | sidePagination: 'server', 48 | pageSize: 10, 49 | pageList: [5, 10, 25, 50, 100], 50 | rowStyle: function (row, index) { 51 | var ageClass = ''; 52 | if (row.age < 18) { 53 | ageClass = 'text-danger'; 54 | } 55 | return {classes: ageClass} 56 | }, 57 | }); 58 | 59 | // 设置bootbox中文 60 | bootbox.setLocale('zh_CN'); 61 | 62 | var titleTip = '提示'; 63 | 64 | function kuaidiRecordInfo(no, company) { 65 | $('#viewModal').modal('show'); 66 | $.ajax({ 67 | type:'get', 68 | url:'getKuaiDiInfoByJson?com='+ company +'&no=' + no, 69 | cache:false, 70 | dataType:'json', 71 | success:function(result){ 72 | // 显示详细信息 发送请求通过单号 73 | $("#viewDataList").empty(); 74 | console.log(result.data); 75 | var dataList = result.data; 76 | if(null != dataList){ 77 | $("#viewDataList").append('
  • 快递单号:'+ result.nu +'
  • '); 78 | $("#kuaidi").append('
    地点和跟踪进度
      '); 79 | for(var i=0;i
      '+ kuaiRecodList.ftime + '
      '+ kuaiRecodList.context +'
      '); 83 | }else{ 84 | $("#reordList").append('
    • '+ kuaiRecodList.ftime + '
      '+ kuaiRecodList.context +'
    • '); 85 | } 86 | } 87 | } 88 | 89 | } 90 | }); 91 | 92 | } 93 | // 验证输入的年龄是否为数字 94 | function verifyAge(age) { 95 | var reg = /^[0-9]{0,3}$/; 96 | if (!reg.test(age)) { 97 | return false; 98 | } 99 | return true; 100 | } 101 | 102 | // 验证姓名和地址是否为空 103 | function verifyNameAndAddress(name, address) { 104 | if (name != '' && address != '') { 105 | return true; 106 | } 107 | return false; 108 | } 109 | 110 | function nullAlert() { 111 | bootbox.alert({ 112 | title: titleTip, 113 | message: '所有项均为必填!' 114 | }); 115 | } 116 | 117 | // 点击查询按钮,年龄符合查询条件方可跳转查询 118 | $('#queryBtn').click(function () { 119 | var age = $('#queryAgeText').val(); 120 | // if (verifyAge(age)) { 121 | // 刷新并跳转到第一页 122 | $testTable.bootstrapTable('selectPage', 1); 123 | // } else { 124 | // bootbox.alert({ 125 | // title: titleTip, 126 | // message: '年龄输入有误!' 127 | // }); 128 | // } 129 | }); 130 | 131 | // 点击重置按钮,清空查询条件并跳转回第一页 132 | $('#resetBtn').click(function() { 133 | $('.form-group :text').val(''); 134 | $testTable.bootstrapTable('selectPage', 1); 135 | }); 136 | 137 | // 用于修改服务器资源 138 | function exchangeData(path, id, userName, phone, kuaiDiNo, company) { 139 | $.ajax({ 140 | url: path, 141 | type: 'post', 142 | data : { 143 | id: id, 144 | userName: userName, 145 | phone: phone, 146 | kuaiDiNo: kuaiDiNo, 147 | company: company 148 | }, 149 | success: function(res) { 150 | bootbox.alert({ 151 | title: titleTip, 152 | message: res.message 153 | }); 154 | // 在每次提交操作后返回首页 155 | $testTable.bootstrapTable('selectPage', 1); 156 | } 157 | }); 158 | } 159 | 160 | // 新增 161 | $('#addBtn').click(function() { 162 | $('#addNameText').val(''); 163 | $('#addPhoneText').val(''); 164 | $('#addKuaiDiNoText').val(''); 165 | $('#addCompanyText').val(''); 166 | $('#addModal').modal('show'); 167 | }); 168 | 169 | $('#saveAdd').click(function() { 170 | $('#addModal').modal('hide'); 171 | bootbox.confirm({ 172 | title: titleTip, 173 | message: '确认增加?', 174 | callback: function (flag) { 175 | if (flag) { 176 | var userName = $('#addNameText').val(); 177 | var phone = $('#addPhoneText').val(); 178 | var kuaiDiNo = $('#addKuaiDiNoText').val(); 179 | var company = $('#addCompanyText').val(); 180 | if (verifyNameAndAddress(userName, kuaiDiNo)) { 181 | exchangeData('addKuaiDi', null, userName, phone, kuaiDiNo, company); 182 | } else { 183 | nullAlert(); 184 | } 185 | } 186 | } 187 | }); 188 | }); 189 | 190 | var mid; 191 | 192 | // 修改 193 | function modifyKuaiDi(id, name, age, address) { 194 | mid = id; 195 | $('#modifyNameText').val(name); 196 | $('#modifyPhoneText').val(age); 197 | $('#modifyKuaiDiNoText').val(address); 198 | $('#modifyCompanyText').val(address); 199 | $('#modifyModal').modal('show'); 200 | } 201 | 202 | $('#saveModify').click(function() { 203 | $('#modifyModal').modal('hide'); 204 | bootbox.confirm({ 205 | title: titleTip, 206 | message: '确认修改?', 207 | callback: function (flag) { 208 | if (flag) { 209 | var userName = $('#modifyNameText').val(); 210 | var phone = $('#modifyPhoneText').val(); 211 | var kuaiDiNo = $('#modifyKuaiDiNoText').val(); 212 | var company = $('#modifyCompanyText').val(); 213 | if (verifyNameAndAddress(userName, phone)) { 214 | exchangeData('modifyKuaiDi', mid, userName, phone, kuaiDiNo, company); 215 | } else { 216 | nullAlert(); 217 | } 218 | } 219 | } 220 | }); 221 | }); 222 | 223 | // 删除 224 | function delKuaiDi(id) { 225 | bootbox.confirm({ 226 | title: titleTip, 227 | message: '确认删除?', 228 | callback: function(flag) { 229 | if (flag) { 230 | exchangeData("delKuaiDi", id); 231 | } 232 | } 233 | }); 234 | } -------------------------------------------------------------------------------- /src/main/resources/static/mht_search.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 快递单号查询 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 单号查询结果 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 49 | 51 | 52 | 53 | 54 | 58 | 59 | 60 | 61 |
      62 | 63 |
      64 | 79 |
      80 | 81 |

      82 | 快递单号自助查询 83 |

      84 | 85 | 86 |
      87 |
      88 | 89 | 90 |
      91 | 92 |
      93 |
      94 | 95 | 96 |
        97 |
      98 | 99 |
      100 | 101 | 139 | 144 | 145 | --------------------------------------------------------------------------------