• SSM框架+LayUi+Mysql实现的物流配送管理系统(功能包含分角色,登录/注册、车辆管理/路线管理/运单管理/调度安排/信息管理等)


    SSM框架+LayUi+Mysql实现的物流配送管理系统

    本系统为了解决物流平台的配送难题,将司机/物流配送的整体流程话,便于物流公司的统一管理,提高了物流日常工作的高效。
    (文末查看完整源码)

    实现功能截图

    车辆管理
    在这里插入图片描述
    路线管理
    在这里插入图片描述
    运单管理
    在这里插入图片描述
    调度安排
    在这里插入图片描述
    皮肤设置
    在这里插入图片描述

    系统功能

    本系统实现了以下功能:
    1、注册登录
    2、权限分配
    3、员工管理
    4、车辆管理
    5、路线管理
    6、运单管理
    7、调度安排
    8、其他信息管理

    使用技术

    数据库:mysql
    开发工具:Idea(Myeclispe、Eclipse也可以)
    知识点:SSM框架

    项目结构
    在这里插入图片描述

    代码

    java端
    entity实体
    Admin.java

    package com.wbg.logistics.entity;
    
    public class Admin {
        /**
         *
         * This field was generated by MyBatis Generator.
         * This field corresponds to the database column admin.a_id
         *
         * @mbg.generated
         */
        private Integer aId;
    
        /**
         *
         * This field was generated by MyBatis Generator.
         * This field corresponds to the database column admin.a_account
         *
         * @mbg.generated
         */
        private String aAccount;
    
        /**
         *
         * This field was generated by MyBatis Generator.
         * This field corresponds to the database column admin.a_password
         *
         * @mbg.generated
         */
        private String aPassword;
    
        /**
         *
         * This field was generated by MyBatis Generator.
         * This field corresponds to the database column admin.a_rank
         *
         * @mbg.generated
         */
        private String aRank;
    
        /**
         * This method was generated by MyBatis Generator.
         * This method returns the value of the database column admin.a_id
         *
         * @return the value of admin.a_id
         *
         * @mbg.generated
         */
        public Integer getaId() {
            return aId;
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method sets the value of the database column admin.a_id
         *
         * @param aId the value for admin.a_id
         *
         * @mbg.generated
         */
        public void setaId(Integer aId) {
            this.aId = aId;
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method returns the value of the database column admin.a_account
         *
         * @return the value of admin.a_account
         *
         * @mbg.generated
         */
        public String getaAccount() {
            return aAccount;
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method sets the value of the database column admin.a_account
         *
         * @param aAccount the value for admin.a_account
         *
         * @mbg.generated
         */
        public void setaAccount(String aAccount) {
            this.aAccount = aAccount == null ? null : aAccount.trim();
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method returns the value of the database column admin.a_password
         *
         * @return the value of admin.a_password
         *
         * @mbg.generated
         */
        public String getaPassword() {
            return aPassword;
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method sets the value of the database column admin.a_password
         *
         * @param aPassword the value for admin.a_password
         *
         * @mbg.generated
         */
        public void setaPassword(String aPassword) {
            this.aPassword = aPassword == null ? null : aPassword.trim();
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method returns the value of the database column admin.a_rank
         *
         * @return the value of admin.a_rank
         *
         * @mbg.generated
         */
        public String getaRank() {
            return aRank;
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method sets the value of the database column admin.a_rank
         *
         * @param aRank the value for admin.a_rank
         *
         * @mbg.generated
         */
        public void setaRank(String aRank) {
            this.aRank = aRank == null ? null : aRank.trim();
        }
    }
    
    • 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
    • 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
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135

    Depart.java

    package com.wbg.logistics.entity;
    
    import org.springframework.format.annotation.DateTimeFormat;
    
    import java.util.Date;
    
    public class Depart {
        private Firm firm;
    
        private Dispatch dispatch;
    
        @Override
        public String toString() {
            return "Depart{" +
                    "firm=" + firm +
                    ", dispatch=" + dispatch +
                    ", staffNo=" + staffNo +
                    ", staffName='" + staffName + '\'' +
                    ", gender='" + gender + '\'' +
                    ", birthhday=" + birthhday +
                    ", phone='" + phone + '\'' +
                    ", password='" + password + '\'' +
                    ", dedpartNo=" + dedpartNo +
                    ", firmNo=" + firmNo +
                    '}';
        }
    
        public Firm getFirm() {
            return firm;
        }
    
        public void setFirm(Firm firm) {
            this.firm = firm;
        }
    
        public Dispatch getDispatch() {
            return dispatch;
        }
    
        public void setDispatch(Dispatch dispatch) {
            this.dispatch = dispatch;
        }
    
        /**
         *
         * This field was generated by MyBatis Generator.
         * This field corresponds to the database column depart.staff_no
         *
         * @mbg.generated
         */
        private Integer staffNo;
    
        /**
         *
         * This field was generated by MyBatis Generator.
         * This field corresponds to the database column depart.staff_name
         *
         * @mbg.generated
         */
        private String staffName;
    
        /**
         *
         * This field was generated by MyBatis Generator.
         * This field corresponds to the database column depart.gender
         *
         * @mbg.generated
         */
        private String gender;
    
        /**
         *
         * This field was generated by MyBatis Generator.
         * This field corresponds to the database column depart.birthhday
         *
         * @mbg.generated
         */
        @DateTimeFormat(pattern = "yyyy-MM-dd")
        private Date birthhday;
    
        /**
         *
         * This field was generated by MyBatis Generator.
         * This field corresponds to the database column depart.phone
         *
         * @mbg.generated
         */
        private String phone;
    
        /**
         *
         * This field was generated by MyBatis Generator.
         * This field corresponds to the database column depart.password
         *
         * @mbg.generated
         */
        private String password;
    
        /**
         *
         * This field was generated by MyBatis Generator.
         * This field corresponds to the database column depart.dedpart_no
         *
         * @mbg.generated
         */
        private Integer dedpartNo;
    
        /**
         *
         * This field was generated by MyBatis Generator.
         * This field corresponds to the database column depart.firm_no
         *
         * @mbg.generated
         */
        private Integer firmNo;
    
        /**
         * This method was generated by MyBatis Generator.
         * This method returns the value of the database column depart.staff_no
         *
         * @return the value of depart.staff_no
         *
         * @mbg.generated
         */
        public Integer getStaffNo() {
            return staffNo;
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method sets the value of the database column depart.staff_no
         *
         * @param staffNo the value for depart.staff_no
         *
         * @mbg.generated
         */
        public void setStaffNo(Integer staffNo) {
            this.staffNo = staffNo;
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method returns the value of the database column depart.staff_name
         *
         * @return the value of depart.staff_name
         *
         * @mbg.generated
         */
        public String getStaffName() {
            return staffName;
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method sets the value of the database column depart.staff_name
         *
         * @param staffName the value for depart.staff_name
         *
         * @mbg.generated
         */
        public void setStaffName(String staffName) {
            this.staffName = staffName == null ? null : staffName.trim();
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method returns the value of the database column depart.gender
         *
         * @return the value of depart.gender
         *
         * @mbg.generated
         */
        public String getGender() {
            return gender;
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method sets the value of the database column depart.gender
         *
         * @param gender the value for depart.gender
         *
         * @mbg.generated
         */
        public void setGender(String gender) {
            this.gender = gender == null ? null : gender.trim();
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method returns the value of the database column depart.birthhday
         *
         * @return the value of depart.birthhday
         *
         * @mbg.generated
         */
        public Date getBirthhday() {
            return birthhday;
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method sets the value of the database column depart.birthhday
         *
         * @param birthhday the value for depart.birthhday
         *
         * @mbg.generated
         */
        public void setBirthhday(Date birthhday) {
            this.birthhday = birthhday;
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method returns the value of the database column depart.phone
         *
         * @return the value of depart.phone
         *
         * @mbg.generated
         */
        public String getPhone() {
            return phone;
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method sets the value of the database column depart.phone
         *
         * @param phone the value for depart.phone
         *
         * @mbg.generated
         */
        public void setPhone(String phone) {
            this.phone = phone == null ? null : phone.trim();
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method returns the value of the database column depart.password
         *
         * @return the value of depart.password
         *
         * @mbg.generated
         */
        public String getPassword() {
            return password;
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method sets the value of the database column depart.password
         *
         * @param password the value for depart.password
         *
         * @mbg.generated
         */
        public void setPassword(String password) {
            this.password = password == null ? null : password.trim();
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method returns the value of the database column depart.dedpart_no
         *
         * @return the value of depart.dedpart_no
         *
         * @mbg.generated
         */
        public Integer getDedpartNo() {
            return dedpartNo;
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method sets the value of the database column depart.dedpart_no
         *
         * @param dedpartNo the value for depart.dedpart_no
         *
         * @mbg.generated
         */
        public void setDedpartNo(Integer dedpartNo) {
            this.dedpartNo = dedpartNo;
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method returns the value of the database column depart.firm_no
         *
         * @return the value of depart.firm_no
         *
         * @mbg.generated
         */
        public Integer getFirmNo() {
            return firmNo;
        }
    
        /**
         * This method was generated by MyBatis Generator.
         * This method sets the value of the database column depart.firm_no
         *
         * @param firmNo the value for depart.firm_no
         *
         * @mbg.generated
         */
        public void setFirmNo(Integer firmNo) {
            this.firmNo = firmNo;
        }
    }
    
    • 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
    • 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
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245
    • 246
    • 247
    • 248
    • 249
    • 250
    • 251
    • 252
    • 253
    • 254
    • 255
    • 256
    • 257
    • 258
    • 259
    • 260
    • 261
    • 262
    • 263
    • 264
    • 265
    • 266
    • 267
    • 268
    • 269
    • 270
    • 271
    • 272
    • 273
    • 274
    • 275
    • 276
    • 277
    • 278
    • 279
    • 280
    • 281
    • 282
    • 283
    • 284
    • 285
    • 286
    • 287
    • 288
    • 289
    • 290
    • 291
    • 292
    • 293
    • 294
    • 295
    • 296
    • 297
    • 298
    • 299
    • 300
    • 301
    • 302
    • 303
    • 304
    • 305
    • 306
    • 307
    • 308

    dao层
    AdminMapper.java

    package com.wbg.logistics.dao;
    
    import com.wbg.logistics.entity.Admin;
    import java.util.List;
    
    public interface AdminMapper {
        /**
         * This method was generated by MyBatis Generator.
         * This method corresponds to the database table admin
         *
         * @mbg.generated
         */
        int deleteByPrimaryKey(Integer aId);
    
        /**
         * This method was generated by MyBatis Generator.
         * This method corresponds to the database table admin
         *
         * @mbg.generated
         */
        int insert(Admin record);
    
        /**
         * This method was generated by MyBatis Generator.
         * This method corresponds to the database table admin
         *
         * @mbg.generated
         */
        Admin selectByPrimaryKey(Integer aId);
    
        /**
         * This method was generated by MyBatis Generator.
         * This method corresponds to the database table admin
         *
         * @mbg.generated
         */
        List<Admin> selectAll();
    
        /**
         * This method was generated by MyBatis Generator.
         * This method corresponds to the database table admin
         *
         * @mbg.generated
         */
        int updateByPrimaryKey(Admin record);
    }
    
    • 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
    • 46

    DepartMapper.java

    package com.wbg.logistics.dao;
    
    import com.wbg.logistics.entity.Depart;
    import com.wbg.logistics.entity.Dispatch;
    
    import java.util.List;
    
    public interface DepartMapper {
        /**
         * This method was generated by MyBatis Generator.
         * This method corresponds to the database table depart
         *
         * @mbg.generated
         */
        int deleteByPrimaryKey(Integer staffNo);
    
        /**
         * This method was generated by MyBatis Generator.
         * This method corresponds to the database table depart
         *
         * @mbg.generated
         */
        int insert(Depart record);
    
        /**
         * This method was generated by MyBatis Generator.
         * This method corresponds to the database table depart
         *
         * @mbg.generated
         */
        List<Depart> selectByPrimaryKey(Integer staffNo);
    
        /**
         * This method was generated by MyBatis Generator.
         * This method corresponds to the database table depart
         *
         * @mbg.generated
         */
        List<Depart> selectAll();
        List<Depart> selectAllJson();
        List<Depart> selectByType(String staffName);
        /**
         * This method was generated by MyBatis Generator.
         * This method corresponds to the database table depart
         *
         * @mbg.generated
         */
        int updateByPrimaryKey(Depart record);
    }
    
    • 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
    • 46
    • 47
    • 48
    • 49

    controller层
    AdminMapperController.java

    package com.wbg.logistics.controller;
    
    import com.wbg.logistics.dao.AdminMapper;
    import com.wbg.logistics.entity.Admin;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import org.springframework.ui.Model;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.bind.annotation.RequestParam;
    
    import java.util.List;
    
    @Controller
    @RequestMapping("/admin")
    public class AdminMapperController {
        @Autowired
        private AdminMapper adminMapper;
    
        @RequestMapping(method = RequestMethod.GET)
        public String index(@RequestParam(defaultValue = "1") int page, Model model){
            List<Admin> authodList=adminMapper.selectAll();
            model.addAttribute("authod",authodList);
            return "/employee";
        }
    }
    
    • 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

    DepartController.java

    package com.wbg.logistics.controller;
    
    import com.github.pagehelper.PageHelper;
    import com.github.pagehelper.PageInfo;
    import com.wbg.logistics.dao.DepartMapper;
    import com.wbg.logistics.entity.Depart;
    import com.wbg.logistics.util.DBUtil;
    import com.wbg.logistics.util.R;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.format.annotation.DateTimeFormat;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.*;
    import org.springframework.web.servlet.mvc.support.RedirectAttributes;
    
    import javax.ws.rs.PathParam;
    import java.util.Date;
    import java.util.List;
    
    @Controller
    @RequestMapping("/depart")
    public class DepartController {
    
        @Autowired
        private DepartMapper departMapper;
        @RequestMapping(value = "/json",method = RequestMethod.GET)
        @ResponseBody
        public String selectAllJson(@RequestParam("page") int page ,@RequestParam("limit") int limit){
            PageHelper.startPage(page,limit);
            R r=new R();
            List<Depart> list=departMapper.selectAllJson();
            PageInfo pi = new PageInfo(list);
            r.setMsg("ok");
            r.setData(list);
            r.setCount((int)pi.getTotal());
            return r.toJsonyMd();
        }
        @RequestMapping(value = "/add", method = RequestMethod.GET)
        public String add(Depart depart, RedirectAttributes redirectAttributes) {
            try {
                if (departMapper.insert(depart) > 0) {
                    redirectAttributes.addAttribute("msg", "添加成功");
                    redirectAttributes.addAttribute("routeName","");
                    redirectAttributes.addAttribute("staff", "");
                }
                else{
                    redirectAttributes.addAttribute("msg","添加失败");
    
                }
            }catch (Exception e){
                redirectAttributes.addAttribute("msg","添加失败");
    
                return "redirect:/depart";
            }
            return "redirect:/depart";
        }
    
        @RequestMapping(value = "/update", method = RequestMethod.POST)
        @ResponseBody
        public String update(@RequestBody Depart depart) {
            R r = new R();
            try{
                if (departMapper.updateByPrimaryKey(depart) > 0) {
                    r.setMsg("修改成功");
                    r.setCode(3);
                } else
                    r.setMsg("修改失败");
            }catch (Exception e){
                r.setMsg("修改失败");
                return r.toJsonyMd();
            }
    
    
            return r.toJsonyMd();
        }
    
        @RequestMapping(value = "/del/{departNo}", method = RequestMethod.POST)
        @ResponseBody
        public String del(@PathVariable("departNo") int departNo) {
            R r = new R();
            try {
                if (departMapper.deleteByPrimaryKey(departNo) > 0) {
                    r.setMsg("删除成功");
                    r.setCode(3);
                } else
                    r.setMsg("删除失败");
            }catch (Exception e){
                r.setMsg("删除失败,可能存在员工");
                return r.toJsonyMd();
            }
            return r.toJsonyMd();
        }
        @RequestMapping(method = RequestMethod.GET)
        public String index(){
            return "employeeadd";
        }
    
        @RequestMapping(value = "/ById/{staffNo}", method = RequestMethod.GET)
        @ResponseBody
        public String seleById(@PathVariable("staffNo") int staffNo){
            R r=new R();
            List<Depart> list=departMapper.selectByPrimaryKey(staffNo);
            r.setMsg("ok");
            r.setData(list);
            r.setCount(1);
            return r.toJson();
        }
        @RequestMapping(value = "/ByName/{staffName}", method = RequestMethod.GET)
        @ResponseBody
        public String seleByName(@PathVariable("staffName") String staffName){
            R r=new R();
            List<Depart> list=departMapper.selectByType("%"+staffName+"%");
            PageInfo pi = new PageInfo(list);
            r.setMsg("ok");
            r.setData(list);
            r.setCount((int)pi.getTotal());
            return r.toJson();
        }
    
    }
    
    
    • 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
    • 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
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120

    DBUtil.java

    package com.wbg.logistics.util;
    
    import com.fasterxml.jackson.core.JsonParseException;
    import com.fasterxml.jackson.core.JsonProcessingException;
    import com.fasterxml.jackson.databind.JsonMappingException;
    import com.fasterxml.jackson.databind.ObjectMapper;
    import com.sun.jmx.snmp.Timestamp;
    
    import java.io.IOException;
    import java.text.ParsePosition;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    
    public class DBUtil {
        public static String toJson(Object obj){
            String reuqest=null;
            //对象映射
            ObjectMapper mapper=new ObjectMapper();
            //设置时间格式
            SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            mapper.setDateFormat(dateFormat);
            try {
                reuqest=mapper.writeValueAsString(obj);
            } catch (JsonProcessingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return reuqest;
        }
        public static String toJsonyMd(Object obj){
            String reuqest=null;
            //对象映射
            ObjectMapper mapper=new ObjectMapper();
            //设置时间格式
            SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd");
            mapper.setDateFormat(dateFormat);
            try {
                reuqest=mapper.writeValueAsString(obj);
            } catch (JsonProcessingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return reuqest;
        }
        public static <T> T toObject(String src,Class<T> valueType){
            T request=null;
            //对象反射
            ObjectMapper mapper=new ObjectMapper();
            try {
                request=mapper.readValue(src, valueType);
            } catch (JsonParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (JsonMappingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return request;
        }
        public static Timestamp date(String date_str) {
            try {
                Calendar zcal = Calendar.getInstance();//日期类
                Timestamp timestampnow = new Timestamp(zcal.getTimeInMillis());//转换成正常的日期格式
                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");//改为需要的东西
                ParsePosition pos = new ParsePosition(0);
                java.util.Date current = formatter.parse(date_str, pos);
                timestampnow = new Timestamp(current.getTime());
                return timestampnow;
            }
            catch (NullPointerException e) {
                return null;
            }
        }
    }
    
    
    • 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
    • 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
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78

    完整源码

    觉得有用,记得一键三连哦!

  • 相关阅读:
    element 去掉form表单的某一项单个form-Item校验
    利用pycharm命令行 上传文件到服务器
    JS-闭包的用法
    如何排查Java内存泄漏?
    Linux 文件系统(一) --- ext4文件系统简介
    C语言——自定义数据类型(结构体内存对齐)
    大型网站系统架构演化实例_6.使用分布式文件系统和分布式数据库系统
    文件操作和IO——JavaEE
    《Java8实战》读书笔记09:用 Optional 处理值为 null 的情况
    c语言练习85:通讯录的实现(基于顺序表实现)
  • 原文地址:https://blog.csdn.net/anmu4200/article/details/127937162