⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 transportserviceimpl.java

📁 一个关于物流的管理系统
💻 JAVA
字号:
package com.shunshi.ssh.service;

import java.util.List;

import org.extremecomponents.table.limit.Limit;

import com.shunshi.ssh.dao.IAllInfoDao;
import com.shunshi.ssh.dao.ITransportDao;
import com.shunshi.ssh.entity.AllInfo;
import com.shunshi.ssh.entity.Goods;
import com.shunshi.ssh.entity.Page;
import com.shunshi.ssh.entity.Transport;
import com.shunshi.ssh.exception.GoodsDaoException;
import com.shunshi.ssh.exception.GoodsServiceException;
import com.shunshi.ssh.exception.TransportDaoException;
import com.shunshi.ssh.exception.TransportServiceException;


public class TransportServiceImpl implements ITransportService {
	private ITransportDao dao;
	private IAllInfoDao dao1;
	public static int DEFAULT_PAGE_SIZE = 5;
	public ITransportDao getDao() {
		return dao;
	}

	public void setDao(ITransportDao dao) {
		this.dao = dao;
	}
	
	public IAllInfoDao getDao1() {
		return dao1;
	}

	public void setDao1(IAllInfoDao dao1) {
		this.dao1 = dao1;
	}

	public void addTransport(Transport transport) throws TransportServiceException{
		try {
			System.out.println("service  addTransport()  ....");
			dao.add(transport);
		} catch (TransportDaoException e) {
			e.printStackTrace();
		}
		
	}

	public void deleteTransport(Long[] ids) throws TransportServiceException{	
			try {
				System.out.println("service  deleteTransport()  ....");
				for(long id:ids)
					dao.delete(id);
			} catch (TransportDaoException e) {
				e.printStackTrace();
			}
	}

	public List findAllTransport() throws TransportServiceException{	
		List l=null;
		try {
			System.out.println("service  findAllTransport()  ....");
			l=dao.findAll();
		} catch (TransportDaoException e) {
			e.printStackTrace();
		}
		return l;
	}

	public Transport findTransportById(long id) throws TransportServiceException{
		Transport t=null;
		try {
			System.out.println("service  findTransportById()  ....");
			t=dao.findById(id);
		} catch (TransportDaoException e) {
			e.printStackTrace();
		}
		return t;
	}

	public List findTransportByUserId(long userId) throws TransportServiceException {
		List l=null;
		 try {
			 System.out.println("service  findTransportByUserId()  ....");
			l=dao.findByUserId(userId);
		} catch (TransportDaoException e) {
			e.printStackTrace();
		}
		return l;
	}

	public void updateState(long id, int state) throws TransportServiceException{
		try {
			System.out.println("service  updateState()  ....");
			dao.updateState(id, state);
		} catch (TransportDaoException e) {
			e.printStackTrace();
		}
		
	}

	public Page findByState(int state, Limit size, int totalRows) throws TransportServiceException {
		try {
			if (totalRows < 0) {
				totalRows = dao.getTotalRowsByState(state).intValue();
			}
			size.setRowAttributes(totalRows, DEFAULT_PAGE_SIZE);
			int[] startAndEnd = new int[] { size.getRowStart(),
					size.getCurrentRowsDisplayed() };

			List l = dao.findByState(state, startAndEnd[0], startAndEnd[1]);
			Page page = new Page(size.getRowStart(), totalRows, size.getPage(),l);
			return page;
		} catch (TransportDaoException e) {
			throw new TransportServiceException(e.getMessage());
		}
	}

	public void updateTransport(Transport transport)
			throws TransportServiceException {
			try {
				dao.updateTransport(transport);
			} catch (TransportDaoException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	}

	public AllInfo getAllInfo() {
		Transport transport=null;
			try {
				transport = dao.findTransportByMaxId();
			} catch (GoodsDaoException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	
		AllInfo info=new AllInfo();
		info.setName(transport.getTopic());
		info.setType("车源信息");
		info.setClassType("transport");
		info.setUserId(transport.getUserId());
		info.setBid(transport.getId());
		return info;
		
	}
	public void saveAllInfo(AllInfo allInfo){
		dao1.addInfo(allInfo);
	}

	public void deleteAll(Long id, String type)
			throws TransportServiceException {
		dao1.deleteObject(dao1.findAllInfo(type, id));
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -