基于Springboot實現(xiàn)送水公司信息管理系統(tǒng)
項目編號:BS-XX-014
項目描述
springboot實現(xiàn)的送水后臺管理系統(tǒng)
運行環(huán)境
jdk8+tomcat7+mysql+IntelliJ IDEA+maven
項目技術(必填)
SpringBoot+mybatis
數(shù)據(jù)庫文件(可選)
壓縮包自帶
依賴包文件(可選)
maven項目
項目運行截圖:

系統(tǒng)主界面
客戶管理

送水工管理

送水歷史訂單

工資計算

統(tǒng)計送水數(shù)量

package com.minzu.service.impl;
import cn.hutool.crypto.digest.DigestUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.minzu.entities.Account;
import com.minzu.mapper.AccountMapper;
import com.minzu.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Objects;
/**
* TODO:登錄業(yè)務邏輯實現(xiàn)類
* 被@Service注解修飾的類是業(yè)務邏輯實現(xiàn)類
* @author znz
* @version 1.0
* @date 2022/1/2 16:25
*/
@Service
public class AccountServiceImpl implements AccountService {
/**
* service依賴mapper,程序運行期SpringBoot容器自動幫我們
* 按照類型裝配(將AccountMapper對象自動裝配到AccountServiceImpl里面)
*/
@Autowired
private AccountMapper accountMapper;
/**
* 處理用戶登錄的業(yè)務邏輯
* 步驟:
* 1 根據(jù)用戶名查詢對應的賬戶
* 2 判斷賬戶對象(Account)是否為空
* 3 如果為空登錄失敗(數(shù)據(jù)庫沒有這個用戶),返回false
* 4 如果非空,對表單輸入的密碼進行MD5加密
* 5 判斷加密之后的密碼和數(shù)據(jù)庫的密碼是否相等
* 6 如果相等登錄成功,返回true
* 7 如果不相等登錄失敗,返回false
*
* @param userName 瀏覽器表單輸入的用戶名
* @param userPwd 瀏覽器表單輸入的密碼
* @return 登錄成功返回true,否則返回false
*/
@Override
public boolean login(String userName, String userPwd) {
// 封裝查詢條件
QueryWrapper<Account> qw = new QueryWrapper<>();
qw.eq("user_name",userName);
// 根據(jù)用戶名查詢對應的賬戶
Account account = accountMapper.selectOne(qw);
// 條件成立:表示沒有對應的賬戶,登錄失敗,返回false
if (null == account) {
return false;
}
// 對表單輸入的密碼進行加密
// encodingPwd存儲加密之后的密碼
String encodingPwd = DigestUtil.md5Hex(userPwd);
// 將加密之后的密碼和數(shù)據(jù)庫密碼進行比較,條件成立:登錄成功,返回true。否則登錄失敗,返回false
if (Objects.equals(encodingPwd,account.getUserPwd())) {
return true;
} else {
return false;
}
}
}package com.minzu.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.minzu.entities.Customer;
import com.minzu.mapper.CustomerMapper;
import com.minzu.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* TODO: 客戶管理業(yè)務邏輯接口的實現(xiàn)類
* 被@Service注解修飾的類是接口實現(xiàn)類,SpringBoot啟動的時候會自動注入
* @author znz
* @version 1.0
* @date 2022/1/1 8:27
*/
@Service
public class CustomerServiceImpl implements CustomerService {
/**
* 自動裝配客戶管理Mapper接口
*/
@Autowired
private CustomerMapper customerMapper;
/**
* 查詢所有的客戶信息
*
* @return 客戶列表
*/
@Override
public List<Customer> listCustomer() {
return customerMapper.selectList(null);
}
/**
* 添加客戶信息
*
* @param customer 需要添加的客戶對象
* @return 受影響行數(shù),大于0添加成功,否則添加失敗
*/
@Override
public int saveCustomer(Customer customer) {
return customerMapper.insert(customer);
}
/**
* 根據(jù)客戶名稱搜索滿足條件的客戶列表
* 例如:例如:使用模糊查詢,搜索所有包含“老”的客戶信息
* 步驟:
* 1 定義QueryWrapper對象
* 2 定義查詢條件
* 3 調(diào)用CustomerMapper對象的selectList方法,將QueryWrapper對象注入到該方法中
* 4 返回搜索結果
* @param userName 搜索的查詢條件
* @return 滿足條件的客戶列表
*/
@Override
public List<Customer> searchCustomer(String userName) {
QueryWrapper<Customer> qw = new QueryWrapper<>();
qw.like("cust_name",userName);
List<Customer> custList = customerMapper.selectList(qw);
return custList;
}
/**
* 根據(jù)客戶ID刪除客戶信息
* 步驟:
* 1 創(chuàng)建QueryWrapper對象
* 2 設置要刪除的條件
* 3 根據(jù)id刪除客戶信息,返回受影響行數(shù)
* @param cid 客戶ID
* @return 受影響行數(shù),大于0刪除成功,否則刪除失敗
*/
@Override
public int deleteCustomerById(Integer cid) {
QueryWrapper<Customer> qw = new QueryWrapper<>();
qw.eq("cid",cid);
return customerMapper.delete(qw);
}
/**
* 根據(jù)客戶id查詢對應的客戶信息
* 步驟:
* 1 創(chuàng)建QueryWrapper對象
* 2 設置查詢條件
* 3 調(diào)用CustomerMapper對象selectOne方法,并將QueryWrapper對象注入到該方法中,返回客戶信息
* @param cid 客戶id
* @return 客戶信息
*/
@Override
public Customer getCustomerById(Integer cid) {
QueryWrapper<Customer> qw = new QueryWrapper<>();
qw.eq("cid",cid);
return customerMapper.selectOne(qw);
}
/**
* 修改客戶信息
* 步驟:
* 1 創(chuàng)建QueryWrapper對象
* 2 設置要修改的條件(根據(jù)ID進行修改)
* 3 調(diào)用CustomerMapper的update方法修改客戶信息,并返回受影響行數(shù)
* @param customer 采集的客戶信息
* @return 受影響行數(shù)
*/
@Override
public int updateCustomer(Customer customer) {
QueryWrapper<Customer> qw = new QueryWrapper<>();
qw.eq("cid",customer.getCid());
return customerMapper.update(customer,qw);
}
}
package com.minzu.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.minzu.entities.History;
import com.minzu.mapper.HistoryMapper;
import com.minzu.service.HistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* TODO: 送水歷史管理接口實現(xiàn)類
*
* @author znz
* @version 1.0
* @date 2022/1/3 8:56
*/
@Service
public class HistoryServiceImpl implements HistoryService {
@Autowired
private HistoryMapper historyMapper;
/**
* 查詢所有的送水歷史信息
* @return 送水歷史列表
*/
@Override
public List<History> listHistory() {
return historyMapper.listHistory();
}
/**
* 添加送水歷史
*
* @param history 表單采集的送水歷史信息
* @return 受影響行數(shù),大于0添加成功,否則添加失敗
*/
@Override
public int saveHistory(History history) {
return historyMapper.saveHistory(history);
}
/**
* 根據(jù)送水歷史ID查詢對應的送水歷史
* 用途:修改之前的數(shù)據(jù)回顯
*
* @param hid 送水歷史ID
* @return 送水歷史信息
*/
@Override
public History getHistoryById(Integer hid) {
return historyMapper.getHistoryById(hid);
}
/**
* 修改送水歷史
*
* @param history 表單采集的的送水歷史信息
* @return update語句受影響行數(shù),大于0修改成功,否則修改失敗
*/
@Override
public int updateHistory(History history) {
return historyMapper.updateHistory(history);
}
/**
* 批量刪除
*
* @param idList 需要批量刪除的送水歷史id列表
* @return 受影響行數(shù),大于0批量刪除成功,否批量刪除失敗
*/
@Override
public int batchDeleteHistory(String idList) {
// 字符串轉(zhuǎn)換為List集合
String[] split = StrUtil.split(idList, ",");
List<Integer> ids = new ArrayList<>();
for (String id : split) {
if (StrUtil.isNotEmpty(id)) {
ids.add(Integer.parseInt(id));
}
}
return historyMapper.batchDeleteHistory(ids);
}
}package com.minzu.service.impl;
import cn.hutool.core.util.StrUtil;
import com.minzu.entities.Salary;
import com.minzu.entities.Worker;
import com.minzu.mapper.SalaryMapper;
import com.minzu.service.SalaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* TODO: 計算工資業(yè)務邏輯實現(xiàn)類
* @author znz
* @version 1.0
* @date 2022/1/2 8:38
*/
@Service
public class SalaryServiceImpl implements SalaryService {
/**
* 自動裝配SalaryMapper對象
*/
@Autowired
private SalaryMapper salaryMapper;
/**
* 計算所有送水工的工資
* @return 工資列表
*/
@Override
public List<Salary> listCalcSalary() {
return salaryMapper.listCalcSalary();
}
/**
* 根據(jù)條件計算某一段時間的送水工工資
*
* @param startDate 開始時間
* @param endDate 結束時間
* @return 工資列表
*/
@Override
public List<Salary> listCalcSalaryByCondition(String startDate, String endDate) {
// 條件成立:表示輸入的結束時間為Null,將系統(tǒng)當前時間作為結束時間
if(StrUtil.isEmpty(endDate)){
long currentTime = System.currentTimeMillis();
Date dt = new Date(currentTime);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
endDate = sdf.format(dt);
}
// salaryList 在某個時間段已經(jīng)為客戶送過水的送水工信息
List<Salary> salaryList = salaryMapper.listCalcSalaryByCondition(startDate, endDate);
// 沒有為客戶送過水的送水工信息
List<Worker> workerList = salaryMapper.queryNonSendWaterWorker();
// 獲取以送水的送水工名稱
List<String> workerNameList =
salaryList.stream()
.map(Salary::getWorkerName)
.collect(Collectors.toList());
// 將沒有送水的送水工信息合并到salaryList
// 遍歷workerList,將worker對象的數(shù)據(jù)注入到Salary對象中,讓后添加到salaryList集合
workerList.forEach(worker->{
// 條件成立:表示沒有沒有送水的送水工在salaryList集合中不存在,將其放入集合
if (!workerNameList.contains(worker.getWorkerName())){
Salary sa = new Salary();
sa.setWorkerName(worker.getWorkerName());
sa.setWorkerSalary(worker.getWorkerSalary());
sa.setWorkerMoney(worker.getWorkerMoney());
// 沒有送水的送水工默認送水數(shù)量為0
sa.setSendWaterCount(0);
// 沒有送水的送水工默認實發(fā)工資為基本工資
sa.setFinalSalary(Double.valueOf(worker.getWorkerSalary()));
salaryList.add(sa);
}
});
// 將“實發(fā)工資”按照降序排序
// 需要對每個送水工的”實發(fā)工資“進行比較
Collections.sort(salaryList,(o1,o2)->{
if(o1.getFinalSalary() > o2.getFinalSalary()){
return -1;
} else if (o1.getFinalSalary() < o2.getFinalSalary()){
return 1;
} else {
return 0;
}
});
// Collections.sort(salaryList, new Comparator<Salary>() {
// @Override
// public int compare(Salary o1, Salary o2) {
// if(o1.getFinalSalary() > o2.getFinalSalary()){
// return -1;
// } else if(o1.getFinalSalary() < o2.getFinalSalary()) {
// return 1;
// } else {
// return 0;
// }
// }
// });
return salaryList;
}
}package com.minzu.service.impl;
import com.minzu.entities.WaterDetails;
import com.minzu.mapper.WaterDetailsMapper;
import com.minzu.service.WaterDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* TODO
*
* @author znz
* @version 1.0
* @date 2022/1/2 15:36
*/
@Service
public class WaterDetailsServiceImpl implements WaterDetailsService {
@Autowired
private WaterDetailsMapper waterDetailsMapper;
/**
* 查詢每個送水工送水的詳細信息
*
* @return 送水信息列表
*/
@Override
public List<WaterDetails> queryWaterDetails() {
return waterDetailsMapper.queryWaterDetails();
}
}到此這篇關于基于Springboot實現(xiàn)送水公司信息管理系統(tǒng)的文章就介紹到這了,更多相關Springboot送水公司信息管理內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
java(swing)+ mysql實現(xiàn)學生信息管理系統(tǒng)源碼
這篇文章主要分享了java mysql實現(xiàn)學生信息管理系統(tǒng)的源碼,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-11-11
SpringBoot使用@Async注解實現(xiàn)異步調(diào)用
這篇文章主要介紹了SpringBoot使用@Async注解實現(xiàn)異步調(diào)用,異步調(diào)用是相對于同步調(diào)用而言的,同步調(diào)用是指程序按預定順序一步步執(zhí)行,每一步必須等到上一步執(zhí)行完后才能執(zhí)行,異步調(diào)用則無需等待,程序執(zhí)行完即可執(zhí)行,可以減少程序執(zhí)行時間,需要的朋友可以參考下2023-10-10
MongoDB中ObjectId的誤區(qū)及引起的一系列問題
這篇文章主要介紹了MongoDB中ObjectId的誤區(qū)及引起的一系列問題,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-12-12
spring @schedule注解如何動態(tài)配置時間間隔
這篇文章主要介紹了spring @schedule注解如何動態(tài)配置時間間隔,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2021-11-11
SpringBoot整合Swagger3生成接口文檔過程解析
這篇文章主要介紹了SpringBoot整合Swagger3生成接口文檔過程解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2020-07-07

