Java畢業(yè)設(shè)計實戰(zhàn)之財務(wù)預(yù)算管理系統(tǒng)的實現(xiàn)
一、項目簡述
功能包括:實現(xiàn)公司對項目的管理。
二、項目運行
環(huán)境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
項目技術(shù):
JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等






用戶信息控制層:
/**
* 用戶信息控制層
*/
@Controller
public class UserInfoController {
@Resource
private UserInfoService userInfoService;
@Resource
private PrivilegeService privilegeService;
@RequestMapping(value = {"/", "login.html"})
public String toLogin(HttpServletRequest request, HttpServletResponse response){
HttpSession session = request.getSession();
if(session.getAttribute(Config.CURRENT_USERNAME)==null){
return "login";
}else {
try {
response.sendRedirect("/pages/index");
} catch (IOException e) {
e.printStackTrace();
return "login";
}
return null;
}
}
// @RequestMapping(value = "/login.do",method = RequestMethod.POST)
@RequestMapping(value = "/login.do")
@ResponseBody
public Result getUserInfo(UserInfo userInfo, HttpServletRequest request, HttpServletResponse response){
boolean userIsExisted = userInfoService.userIsExisted(userInfo);
System.out.println(userIsExisted + " - " + request.getHeader("token"));
userInfo = getUserInfo(userInfo);
if("client".equals(request.getHeader("token")) && !userIsExisted){
//用戶不存在
return ResultUtil.success(-1);
}
if (userIsExisted && userInfo == null){
return ResultUtil.unSuccess("用戶名或密碼錯誤!");
}else {
//將用戶信息存入session
userInfo = setSessionUserInfo(userInfo,request.getSession());
//將當(dāng)前用戶信息存入cookie
setCookieUser(request,response);
return ResultUtil.success("登錄成功", userInfo);
}
}
@RequestMapping("/users/getUsersByWhere/{pageNo}/{pageSize}")
public @ResponseBody Result getUsersByWhere(UserInfo userInfo, @PathVariable int pageNo, @PathVariable int pageSize, HttpSession session){
if ("".equals(userInfo.getHouseid())){
userInfo.setHouseid(null);
}
if (userInfo.getRoleid() == -1){
userInfo.setRoleid(Config.getSessionUser(session).getRoleid());
}
Utils.log(userInfo.toString());
PageModel model = new PageModel<>(pageNo,userInfo);
model.setPageSize(pageSize);
return userInfoService.getUsersByWhere(model);
}
@RequestMapping("/user/add")
public @ResponseBody Result addUser(UserInfo userInfo){
System.out.println(userInfo);
try {
int num = userInfoService.add(userInfo);
if(num>0){
return ResultUtil.success();
}else {
return ResultUtil.unSuccess();
}
}catch (Exception e){
return ResultUtil.error(e);
}
}
@RequestMapping("/user/update")
public @ResponseBody Result updateUser(UserInfo userInfo){
try {
int num = userInfoService.update(userInfo);
if(num>0){
return ResultUtil.success();
}else {
return ResultUtil.unSuccess();
}
}catch (Exception e){
return ResultUtil.error(e);
}
}
@RequestMapping("/user/del/{id}")
public @ResponseBody Result deleteUser(@PathVariable String id){
try {
int num = userInfoService.delete(id);
if(num>0){
return ResultUtil.success();
}else {
return ResultUtil.unSuccess();
}
}catch (Exception e){
return ResultUtil.error(e);
}
}
@RequestMapping("/getSessionUser")
@ResponseBody
public UserInfo getSessionUser(HttpSession session){
UserInfo sessionUser = (UserInfo) session.getAttribute(Config.CURRENT_USERNAME);
sessionUser.setPassword(null);
return sessionUser;
}
@RequestMapping("/logout")
public String logout(HttpServletRequest request, HttpServletResponse response){
delCookieUser(request, response);
request.getSession().removeAttribute(Config.CURRENT_USERNAME);
return "login";
}
@RequestMapping("/getAllRoles")
public @ResponseBody Result<Role> getAllRoles(){
try {
List<Role> roles = userInfoService.getAllRoles();
if (roles.size()>0){
return ResultUtil.success(roles);
}else {
return ResultUtil.unSuccess();
}
}catch (Exception e){
return ResultUtil.error(e);
}
}
@RequestMapping("/role/add")
public @ResponseBody Result addRole(Role role){
try {
int num = userInfoService.addRole(role);
if(num>0){
privilegeService.addDefaultPrivilegesWhenAddRole(role.getRoleid().toString());
return ResultUtil.success();
}else {
return ResultUtil.unSuccess();
}
}catch (Exception e){
return ResultUtil.error(e);
}
}
@RequestMapping("/role/update")
public @ResponseBody Result updateRole(Role role){
try {
int num = userInfoService.updateRole(role);
if(num>0){
return ResultUtil.success();
}else {
return ResultUtil.unSuccess();
}
}catch (Exception e){
return ResultUtil.error(e);
}
}
@RequestMapping("/role/del/{roleid}")
public @ResponseBody Result deleteRole(@PathVariable String roleid){
try {
privilegeService.delPrivilegesWenDelRole(roleid);
int num = userInfoService.deleteRole(roleid);
if(num>0){
return ResultUtil.success();
}else {
privilegeService.addDefaultPrivilegesWhenAddRole(roleid);
return ResultUtil.unSuccess();
}
}catch (Exception e){
return ResultUtil.error(e);
}
}
@RequestMapping("/getRole/{id}")
public @ResponseBody Result getRoleById(@PathVariable String id){
try {
Role role = userInfoService.getRoleById(id);
if(role != null){
return ResultUtil.success(role);
}else {
return ResultUtil.unSuccess();
}
}catch (Exception e){
return ResultUtil.error(e);
}
}
/**
* 登錄時將用戶信息加入cookie中
* @param response
*/
private void setCookieUser(HttpServletRequest request, HttpServletResponse response){
UserInfo user = getSessionUser(request.getSession());
Cookie cookie = new Cookie(Config.CURRENT_USERNAME,user.getUsername()+"_"+user.getId());
//cookie 保存7天
cookie.setMaxAge(60*60*24*7);
response.addCookie(cookie);
}
/**
* 注銷時刪除cookie信息
* @param request
* @param response
*/
private void delCookieUser(HttpServletRequest request, HttpServletResponse response){
UserInfo user = getSessionUser(request.getSession());
Cookie cookie = new Cookie(Config.CURRENT_USERNAME,user.getUsername()+"_"+user.getId());
cookie.setMaxAge(-1);
response.addCookie(cookie);
}
/**
* 通過用戶信息獲取用戶權(quán)限信息,并存入session中
* @param userInfo
* @param session
* @return
*/
public UserInfo setSessionUserInfo(UserInfo userInfo, HttpSession session){
List<Privilege> privileges = privilegeService.getPrivilegeByRoleid(userInfo.getRoleid());
userInfo.setPrivileges(privileges);
session.setAttribute(Config.CURRENT_USERNAME,userInfo);
return userInfo;
}
public UserInfo getUserInfo(UserInfo userInfo){
return userInfoService.getUserInfo(userInfo);
}
}
數(shù)據(jù)圖形展示:
@RestController
@RequestMapping("/bills")
public class BillController {
@Resource
private BillService billService;
/**
* 適用于統(tǒng)計圖
* @param bill
* @return
*/
@RequestMapping("/getBillsToChart")
public Result<Bill> findByWhereNoPage(Bill bill, HttpSession session){
bill = getHouseBill(bill,session);
return billService.findByWhereNoPage(bill);
}
@RequestMapping("/getBillsByWhere/{type}/{pageNo}/{pageSize}")
public Result<Bill> getBillsByWhere(Bill bill,@PathVariable String type, @PathVariable int pageNo, @PathVariable int pageSize, HttpSession session){
if("-1".equals(bill.getPayway())){
bill.setPayway(null);
}
bill.setType(type);
bill = getHouseBill(bill,session);
System.out.println(bill);
PageModel model = new PageModel<>(pageNo,bill);
model.setPageSize(pageSize);
return billService.findByWhere(model);
}
@RequestMapping("/getBillsByUserid/{userid}/{pageNo}/{pageSize}/{year}/{month}")
public Result getBillsByUserid(@PathVariable Integer userid, @PathVariable int pageNo, @PathVariable int pageSize, @PathVariable int year, @PathVariable int month){
Bill bill = new Bill();
bill.setUserid(userid);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
bill.setStartTime(year+"-0"+month+"-01");
try {
Date date = sdf.parse(year+"-0"+(month+1)+"-01");
date.setDate(date.getDate()-1);
bill.setEndTime(sdf.format(date));
} catch (ParseException e) {
e.printStackTrace();
}
PageModel model = new PageModel<>(pageNo,bill);
model.setPageSize(pageSize);
Result result = billService.findByWhere(model);
List<Map<String,String>> r = billService.getMonthlyInfo(model);
Map<String,String> map = new HashMap<>();
for (Map<String,String> m: r) {
map.put(m.get("typeid"),String.format("%.2f",m.get("sum(money)")));
}
result.setData(map);
return result;
}
private Bill getHouseBill(Bill bill, HttpSession session) {
UserInfo currentUser = Config.getSessionUser(session);
//當(dāng)?shù)卿浻脩魹榧抑鲿r,查詢默認(rèn)查詢?nèi)屹~單情況
//當(dāng)?shù)卿浻脩魹槠胀ㄓ脩魰r,僅查詢當(dāng)前用戶的賬單
if (currentUser.getRoleid() == 2){
bill.setHouseid(currentUser.getHouseid());
}else if (currentUser.getRoleid() == 3){
bill.setUserid(currentUser.getId());
}
return bill;
}
@RequestMapping(value = "/addBill",method = RequestMethod.POST)
public Result add(Bill bill, HttpSession session){
if (Config.getSessionUser(session)!=null){
bill.setUserid(Config.getSessionUser(session).getId());
}
Utils.log(bill.toString());
try {
int num = billService.add(bill);
if(num>0){
int billid = bill.getId();
bill = new Bill();
bill.setId(billid);
return ResultUtil.success("記賬成功!",billService.findByWhereNoPage(bill));
// return ResultUtil.success("記賬成功!",bill);
}else {
return ResultUtil.unSuccess();
}
}catch (Exception e){
return ResultUtil.error(e);
}
}
@RequestMapping("/updateBill")
public Result update(Bill bill, HttpSession session){
if (Config.getSessionUser(session)!=null){
bill.setUserid(Config.getSessionUser(session).getId());
}
Utils.log(bill.toString());
try {
int num = billService.update(bill);
if(num>0){
return ResultUtil.success("修改成功!",null);
}else {
return ResultUtil.unSuccess();
}
}catch (Exception e){
return ResultUtil.error(e);
}
}
@RequestMapping("/delBill")
public Result del(int id){
try {
int num = billService.del(id);
if(num>0){
return ResultUtil.success("刪除成功!",null);
}else {
return ResultUtil.unSuccess();
}
}catch (Exception e){
return ResultUtil.error(e);
}
}
@RequestMapping("/getPayways")
public Result<Payway> getAllPayways(){
try {
List<Payway> payways = billService.getAllPayways();
if (payways!=null && payways.size()>0){
return ResultUtil.success(payways);
}else {
return ResultUtil.unSuccess();
}
} catch (Exception e) {
return ResultUtil.error(e);
}
}
}
用戶信息mapper類:
@Repository
public interface UserInfoMapper {
/**
* 獲取單個用戶信息,可用于:
* 1.登錄
* 2.通過用戶某一部分信息獲取用戶完整信息
* @param userInfo
* @return
*/
UserInfo getUserInfo(UserInfo userInfo);
/**
* 注冊
* @param userInfo
* @return
*/
int addUser(UserInfo userInfo);
/**
* 通過username判斷該用戶是否存在
* @param userInfo
* @return
*/
int userIsExisted(UserInfo userInfo);
/**
* 通過條件獲取符合條件的優(yōu)化信息 -- 分頁
* @param model
* @return
*/
List<UserInfo> getUsersByWhere(PageModel<UserInfo> model);
int getToatlByWhere(PageModel<UserInfo> model);
int add(UserInfo userInfo);
int update(UserInfo userInfo);
int delete(String id);
List<Role> getAllRoles();
int addRole(Role role);
int updateRole(Role role);
int deleteRole(String id);
Role getRoleById(String id);
int addHouseId(House house);
}
到此這篇關(guān)于Java畢業(yè)設(shè)計實戰(zhàn)之財務(wù)預(yù)算管理系統(tǒng)的實現(xiàn)的文章就介紹到這了,更多相關(guān)Java 財務(wù)預(yù)算管理內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Java畢業(yè)設(shè)計實戰(zhàn)之健身俱樂部管理系統(tǒng)的實現(xiàn)
- Java畢業(yè)設(shè)計實戰(zhàn)之工作管理系統(tǒng)的實現(xiàn)
- Java畢業(yè)設(shè)計實戰(zhàn)之在線高中考試系統(tǒng)的實現(xiàn)
- Java畢業(yè)設(shè)計實戰(zhàn)之平行志愿管理系統(tǒng)的實現(xiàn)
- Java畢業(yè)設(shè)計實戰(zhàn)之教室預(yù)訂管理系統(tǒng)的實現(xiàn)
- Java畢業(yè)設(shè)計實戰(zhàn)之共享租車信息管理系統(tǒng)的實現(xiàn)
- Java畢業(yè)設(shè)計實戰(zhàn)之寵物醫(yī)院與商城一體的系統(tǒng)的實現(xiàn)
- Java畢業(yè)設(shè)計實戰(zhàn)之生活旅行分享平臺的實現(xiàn)
- Java畢業(yè)設(shè)計實戰(zhàn)之養(yǎng)老院管理系統(tǒng)的實現(xiàn)
相關(guān)文章
Java畢業(yè)設(shè)計實戰(zhàn)之二手書商城系統(tǒng)的實現(xiàn)
這是一個使用了java+JSP+Springboot+maven+mysql+ThymeLeaf+FTP開發(fā)的二手書商城系統(tǒng),是一個畢業(yè)設(shè)計的實戰(zhàn)練習(xí),具有在線書城該有的所有功能,感興趣的朋友快來看看吧2022-01-01
Java實現(xiàn)數(shù)組去除重復(fù)數(shù)據(jù)的方法詳解
這篇文章主要介紹了Java實現(xiàn)數(shù)組去除重復(fù)數(shù)據(jù)的方法,結(jié)合實例形式詳細(xì)分析了java數(shù)組去除重復(fù)的幾種常用方法、實現(xiàn)原理與相關(guān)注意事項,需要的朋友可以參考下2017-09-09
Android開發(fā)Kotlin實現(xiàn)圓弧計步器示例詳解
這篇文章主要為大家介紹了Android開發(fā)Kotlin繪制圓弧計步器示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-06-06

