大家好,又见面了,我是你们的朋友全栈君。
进销存管理系统的功能需求:
1,实现采购订单的持久化,对采购商品入库处理,还有就是采购的退货处理;
2,实现商品的入库、出库操作,查询商品的库存信息,修改商品的仓库号
3,实现销售订单的添加,销售发货处理,并且销售的退货处理
4,实现新建员工培训信息和查询员工培训记录功能
5,实现对商品、供应商、客户资料的管理,对员工用户的管理,最重要的是对系统数据的备份和恢复
代码的截图如下所示:
系统的截图如下所示:
bean层manage的代码如下所示:
package com.xu.bean;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.springframework.stereotype.Component;
/**
*
* @author 公众号:springmeng
*管理员
*id:管理员编号
*name:管理员名字
*password:登录密码
*gender:性别
*age:年龄
*phone number:手机号码
*deptId:部门id
*/
@Entity
@Table(name = "managers")
@Component
public class Managers {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="managers_id")
private Long id;
@Column(name="managers_name")
private String name;
@Column(name="managers_password")
private String password;
@Column(name="managers_gender")
private String gender;
@Column(name="managers_age")
private Long age;
@Column(name="managers_phonenumber")
private String phonenumber;
/*@ManyToOne(cascade=CascadeType.ALL,fetch=FetchType.LAZY,optional=false,targetEntity=Dept.class)
@JoinColumn(name="dept_name")
private String deptName;*/
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getPhonenumber() {
return phonenumber;
}
public void setPhonenumber(String phonenumber) {
this.phonenumber = phonenumber;
}
public Long getAge() {
return age;
}
public void setAge(Long age) {
this.age = age;
}
/*public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}*/
}
dao层MessageRepository的代码如下所示:
package com.xu.dao;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import com.xu.bean.Message;
public interface MessageRepository extends JpaRepository<Message, Long>{
@Query("select count(id) from Message where flag = '未查看'")
public Long findConts();
@Transactional
@Modifying(clearAutomatically = true)
@Query(value ="update message set flag='已查看' where id=?1",nativeQuery=true)
public void updateMessageById(Long id);
}
Mananger的代码如下所示:
package com.xu.service;
import java.util.List;
import com.xu.bean.Employee;
import com.xu.bean.Managers;
import com.xu.bean.Message;
import com.xu.bean.PurchaseItem;
import com.xu.bean.PurchaseOrder;
import com.xu.exception.ServiceException;
public interface ManagerService {
public int register(Managers manager)throws ServiceException;
public Managers login(String name,String password)throws ServiceException;
public int addPurchaseOrder(PurchaseOrder purchase,List<PurchaseItem> purchaseItem)throws ServiceException;
public List<PurchaseOrder> findAllPurchaseOrder()throws ServiceException;
public List<PurchaseOrder> findPurchaseOrderByPage(int currentPage)throws ServiceException;
public Long findPurchaseOrderCount()throws ServiceException;
public Long getTotalPage()throws ServiceException;
public PurchaseOrder delOrderByPurchaseId(Long orderId)throws ServiceException;
public List<PurchaseItem> delPurchaseItemByPurchaseId(Long orderId)throws ServiceException;
public List<PurchaseItem> findPurchaseItemByPurchaseOrderId(Long orderId)throws ServiceException;
public String findFlagByOrderId(Long orderId)throws ServiceException;
public int updateFlagByOrderId(String string, Long orderId)throws ServiceException;
public Employee employeelogin(String name, String password)throws ServiceException;
public int employeeregister(Employee employee)throws ServiceException;
public int updateStockByReturnPurchaseItem(List<PurchaseItem> purchaseItem)throws ServiceException;
public Employee updateEmplyeeByName(Employee employee)throws ServiceException;
public Managers updateManagersByName(Managers managers)throws ServiceException;
public Long findMessageCount()throws ServiceException;
public List<Message> findAllMessage()throws ServiceException;
public Message findMessageById(Long id)throws ServiceException;
public int updateEmployeeById(Long id)throws ServiceException;
public List<Message> findMessageByPage(int i)throws ServiceException;
public Long getMessageTotalPage()throws ServiceException;
public Long findMessageCounts()throws ServiceException;
}
Manager的serviceimp实现:
package com.xu.service.imp;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import com.xu.bean.Employee;
import com.xu.bean.Managers;
import com.xu.bean.Message;
import com.xu.bean.PurchaseItem;
import com.xu.bean.PurchaseOrder;
import com.xu.dao.EmployeeRepository;
import com.xu.dao.GoodsRepository;
import com.xu.dao.ManagerRepository;
import com.xu.dao.MessageRepository;
import com.xu.dao.PurchaseItemRepository;
import com.xu.dao.PurchaseRepository;
import com.xu.dao.StockRepository;
import com.xu.exception.ServiceException;
import com.xu.service.ManagerService;
import com.xu.util.EncoderByMd5;
@Service
public class ManagerServiceImp implements ManagerService{
@Resource
private ManagerRepository managerRepository;
@Resource
private PurchaseRepository purchaseRepository;
@Resource
private PurchaseItemRepository purchaseItemRepository;
@Resource
private EmployeeRepository employeeRepository;
@Resource
private StockRepository stockRepository;
@Resource
private GoodsRepository goodsRepository;
@Resource
private MessageRepository messageReository;
@Override
public int register(Managers manager) throws ServiceException {
managerRepository.save(manager);
return 0;
}
@Override
public Managers login(String name, String password) throws ServiceException {
Managers man = managerRepository.findManagersByName(name);
if(man!=null){
String md5 = EncoderByMd5.Md5(password);
if(md5.equals(man.getPassword())){
return man;
}else{
return null;
}}else{
return null;
}
}
@Override
public int addPurchaseOrder(PurchaseOrder purchase, List<PurchaseItem> purchaseItem) throws ServiceException {
Double total =0D;
for(PurchaseItem item:purchaseItem){
Double price = item.getPrice();
Long count = item.getCount();
Double i = price * count;
total += i;
}
purchase.setSuppliersId(purchaseItem.get(0).getSupplierId());
purchase.setTotal(total);
PurchaseOrder order = purchaseRepository.save(purchase);
for(PurchaseItem item:purchaseItem){
item.setPurchaseOrderId(order.getId());
purchaseItemRepository.save(item);
}
return 1;
}
@Override
public List<PurchaseOrder> findAllPurchaseOrder() {
List<PurchaseOrder> list = purchaseRepository.findAll();
return list;
}
@Override
public Long findPurchaseOrderCount() {
return purchaseRepository.count();
}
@Override
public List<PurchaseOrder> findPurchaseOrderByPage(int pageNum) {
Pageable pageable = new PageRequest(pageNum, 10);
Page<PurchaseOrder> page =purchaseRepository.findAll(pageable);
List<PurchaseOrder> list = new ArrayList<PurchaseOrder>();
for(PurchaseOrder p:page){
list.add(p);
}
return list;
}
@Override
public Long getTotalPage(){
long count = findPurchaseOrderCount();
Long totalPage;
if(count%10==0){
totalPage = count/10;
}else{
totalPage = count/10 +1;
}
return totalPage;
}
@Override
public PurchaseOrder delOrderByPurchaseId(Long orderId) {
PurchaseOrder purchaseOrder = purchaseRepository.findOne(orderId);
purchaseRepository.delete(orderId);
return purchaseOrder;
}
@Override
public List<PurchaseItem> delPurchaseItemByPurchaseId(Long orderId) throws ServiceException {
List<PurchaseItem> purchaseItem = purchaseItemRepository.findPurchaseItemByPurchaseId(orderId);
purchaseItemRepository.delete(orderId);
return purchaseItem;
}
@Override
public List<PurchaseItem> findPurchaseItemByPurchaseOrderId(Long orderId) throws ServiceException {
return purchaseItemRepository.findPurchaseItemByPurchaseId(orderId);
}
@Override
public String findFlagByOrderId(Long orderId) throws ServiceException {
return purchaseRepository.findFlagByOrderId(orderId);
}
@Override
public int updateFlagByOrderId(String string, Long orderId) throws ServiceException {
purchaseRepository.updateFlagByOrderId(string,orderId);
return 1;
}
@Override
public Employee employeelogin(String name, String password) throws ServiceException {
Employee man = employeeRepository.findEmployeeByName(name);
if(man!=null){
String md5 = EncoderByMd5.Md5(password);
if(md5.equals(man.getPassword())){
return man;
}else{
return null;
}
}else{
return null;
}
}
@Override
public int employeeregister(Employee employee) throws ServiceException {
employeeRepository.save(employee);
return 0;
}
@Override
public int updateStockByReturnPurchaseItem(List<PurchaseItem> purchaseItem) throws ServiceException {
for(PurchaseItem pi:purchaseItem){
Long goodsId = goodsRepository.findGoodsIdByGoodsName(pi.getName());
Long count = stockRepository.findCountByGoodsId(goodsId);
stockRepository.updateStockCountByGoodsId(count-pi.getCount(), goodsId);
}
return 0;
}
@Override
public Employee updateEmplyeeByName(Employee employee) throws ServiceException {
employeeRepository.updateEmployeeByName(employee.getAge(),employee.getGender(),employee.getPhonenumber(),employee.getName());
return employeeRepository.findEmployeeByName(employee.getName());
}
@Override
public Managers updateManagersByName(Managers managers) throws ServiceException {
managerRepository.updateManagersByName(managers.getAge(),managers.getGender(),managers.getPhonenumber(),managers.getName());
return managerRepository.findManagersByName(managers.getName());
}
@Override
public Long findMessageCount() throws ServiceException {
return messageReository.findConts();
}
@Override
public List<Message> findAllMessage() throws ServiceException {
return messageReository.findAll();
}
@Override
public Message findMessageById(Long id) throws ServiceException {
return messageReository.findOne(id);
}
@Override
public int updateEmployeeById(Long id) throws ServiceException {
messageReository.updateMessageById(id);
return 1;
}
@Override
public List<Message> findMessageByPage(int i) throws ServiceException {
Pageable pageable = new PageRequest(i, 10);
Page<Message> page =messageReository.findAll(pageable);
List<Message> list = new ArrayList<Message>();
for(Message p:page){
list.add(p);
}
return list;
}
@Override
public Long getMessageTotalPage() throws ServiceException {
long count = findMessageCounts();
Long totalPage;
if(count%10==0){
totalPage = count/10;
}else{
totalPage = count/10 +1;
}
return totalPage;
}
@Override
public Long findMessageCounts() throws ServiceException {
return messageReository.count();
}
}
本系统的源码、文档、均开放,关注公众号:springmeng 回复:进销存全套
谢谢点赞,有问题可评论。
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/138139.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...