Commit e85498f6 authored by 季圣华's avatar 季圣华
Browse files

升级代码结构,采用Maven来管理jar包(10)

parent 11f18afa
package com.jsh.service.materials;
import com.jsh.base.BaseIService;
import com.jsh.util.JshException;
import com.jsh.model.po.AccountHead;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.PageUtil;
public interface AccountHeadIService extends BaseIService<AccountHead>
{
/*
* 获取MaxId
*/
void find(PageUtil<AccountHead> accountHead,String maxid)throws JshException;
}
package com.jsh.service.materials;
import com.jsh.base.BaseService;
import com.jsh.dao.materials.AccountHeadIDAO;
import com.jsh.util.JshException;
import com.jsh.model.po.AccountHead;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.PageUtil;
public class AccountHeadService extends BaseService<AccountHead> implements AccountHeadIService
{
@SuppressWarnings("unused")
private AccountHeadIDAO accountHeadDao;
public void setAccountHeadDao(AccountHeadIDAO accountHeadDao) {
this.accountHeadDao = accountHeadDao;
}
@Override
protected Class<AccountHead> getEntityClass()
{
return AccountHead.class;
}
@Override
public void find(PageUtil<AccountHead> pageUtil, String maxid) throws JshException
{
accountHeadDao.find(pageUtil, maxid);
}
}
package com.jsh.service.materials;
import java.io.InputStream;
import java.util.List;
import net.sf.json.JSONArray;
import com.jsh.base.BaseIService;
import com.jsh.util.JshException;
import com.jsh.model.po.Asset;
import com.jsh.model.po.AccountHead;
import com.jsh.model.po.AccountItem;
import com.jsh.util.PageUtil;
public interface AccountItemIService extends BaseIService<AccountItem>
{
}
package com.jsh.service.materials;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import com.jsh.base.BaseService;
import com.jsh.base.Log;
import com.jsh.util.AssetConstants;
import com.jsh.dao.materials.AccountItemIDAO;
import com.jsh.util.JshException;
import com.jsh.model.po.Asset;
import com.jsh.model.po.AccountHead;
import com.jsh.model.po.AccountItem;
import com.jsh.util.PageUtil;
import com.jsh.util.Tools;
public class AccountItemService extends BaseService<AccountItem> implements AccountItemIService
{
@SuppressWarnings("unused")
private AccountItemIDAO accoumtItemDao;
public void setAccountItemDao(AccountItemIDAO accoumtItemDao) {
this.accoumtItemDao = accoumtItemDao;
}
@Override
protected Class<AccountItem> getEntityClass()
{
return AccountItem.class;
}
}
package com.jsh.service.materials;
import com.jsh.base.BaseIService;
import com.jsh.util.JshException;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.PageUtil;
public interface DepotHeadIService extends BaseIService<DepotHead>
{
/*
* 获取MaxId
*/
void find(PageUtil<DepotHead> depotHead,String maxid)throws JshException;
}
package com.jsh.service.materials;
import com.jsh.base.BaseService;
import com.jsh.dao.materials.DepotHeadIDAO;
import com.jsh.util.JshException;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.PageUtil;
public class DepotHeadService extends BaseService<DepotHead> implements DepotHeadIService
{
@SuppressWarnings("unused")
private DepotHeadIDAO depotHeadDao;
public void setDepotHeadDao(DepotHeadIDAO depotHeadDao) {
this.depotHeadDao = depotHeadDao;
}
@Override
protected Class<DepotHead> getEntityClass()
{
return DepotHead.class;
}
@Override
public void find(PageUtil<DepotHead> pageUtil, String maxid) throws JshException
{
depotHeadDao.find(pageUtil, maxid);
}
}
package com.jsh.service.materials;
import java.io.InputStream;
import java.util.List;
import net.sf.json.JSONArray;
import com.jsh.base.BaseIService;
import com.jsh.util.JshException;
import com.jsh.model.po.Asset;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.DepotItem;
import com.jsh.util.PageUtil;
public interface DepotItemIService extends BaseIService<DepotItem>
{
void findByType(PageUtil<DepotItem> depotItem, String type, Long MId, String MonthTime,Boolean isPrev)throws JshException;
void buyOrSale(PageUtil<DepotItem> depotItem, String type, String subType, Long MId, String MonthTime, String sumType)throws JshException;
/**
* 导出信息
* @return
*/
InputStream exmportExcel(String isAllPage,JSONArray dataArray)throws JshException;
}
package com.jsh.service.materials;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.DecimalFormat;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import com.jsh.base.BaseService;
import com.jsh.base.Log;
import com.jsh.util.AssetConstants;
import com.jsh.dao.materials.DepotItemIDAO;
import com.jsh.util.JshException;
import com.jsh.model.po.Asset;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.DepotItem;
import com.jsh.util.PageUtil;
import com.jsh.util.Tools;
public class DepotItemService extends BaseService<DepotItem> implements DepotItemIService
{
@SuppressWarnings("unused")
private DepotItemIDAO depotItemDao;
public void setDepotItemDao(DepotItemIDAO depotItemDao) {
this.depotItemDao = depotItemDao;
}
@Override
protected Class<DepotItem> getEntityClass()
{
return DepotItem.class;
}
@Override
public void findByType(PageUtil<DepotItem> pageUtil, String type,Long MId, String MonthTime,Boolean isPrev) throws JshException
{
depotItemDao.findByType(pageUtil, type, MId, MonthTime,isPrev);
}
@Override
public void buyOrSale(PageUtil<DepotItem> pageUtil, String type,String subType, Long MId, String MonthTime, String sumType) throws JshException
{
depotItemDao.buyOrSale(pageUtil, type, subType, MId, MonthTime, sumType);
}
/**
* 导出Excel表格
*/
@Override
public InputStream exmportExcel(String isAllPage,JSONArray dataArray)throws JshException
{
try
{
//将OutputStream转化为InputStream
ByteArrayOutputStream out = new ByteArrayOutputStream();
putDataOnOutputStream(out,dataArray);
return new ByteArrayInputStream(out.toByteArray());
}
catch (Exception e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>导出信息为excel表格异常", e);
throw new JshException("export asset info to excel exception",e);
}
}
/**
* 生成excel表格
* @param os
*/
@SuppressWarnings("deprecation")
private void putDataOnOutputStream(OutputStream os,JSONArray dataArray)
{
WritableWorkbook workbook = null;
try
{
workbook = Workbook.createWorkbook(os);
WritableSheet sheet = workbook.createSheet("进销存报表", 0);
//增加列头
int[] colunmWidth = {10,10,10,10,15,15,15,15,15};
String[] colunmName = {"名称","款号","颜色","单价","上月结存数量","入库数量","出库数量","本月结存数量","结存金额"};
for(int i = 0 ;i < colunmWidth.length;i ++)
{
sheet.setColumnView(i,colunmWidth[i]);
sheet.addCell(new Label(i, 0, colunmName[i]));
}
if (null != dataArray &&dataArray.size() > 0)
{
for(int j=0; j < dataArray.size(); j++){
JSONObject jo = JSONObject.fromObject(dataArray.get(j));
sheet.addCell(new Label(0, j+1, jo.getString("MaterialName")));
sheet.addCell(new Label(1, j+1, jo.getString("MaterialModel")));
sheet.addCell(new Label(2, j+1, jo.getString("MaterialColor")));
sheet.addCell(new Label(3, j+1, jo.getString("UnitPrice")));
sheet.addCell(new Label(4, j+1, jo.getString("prevSum")));
sheet.addCell(new Label(5, j+1, jo.getString("InSum")));
sheet.addCell(new Label(6, j+1, jo.getString("OutSum")));
sheet.addCell(new Label(7, j+1, jo.getString("thisSum")));
double d = Double.parseDouble(jo.getString("thisAllPrice").toString());
String s1 = String.format("%.2f", d);
sheet.addCell(new Label(8, j+1, s1));
}
}
workbook.write();
workbook.close();
}
catch (Exception e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>导出资产信息为excel表格异常", e);
}
}
}
package com.jsh.service.materials;
import com.jsh.base.BaseIService;
import com.jsh.model.po.MaterialCategory;
public interface MaterialCategoryIService extends BaseIService<MaterialCategory>
{
}
package com.jsh.service.materials;
import com.jsh.base.BaseService;
import com.jsh.dao.materials.MaterialCategoryIDAO;
import com.jsh.model.po.MaterialCategory;
public class MaterialCategoryService extends BaseService<MaterialCategory> implements MaterialCategoryIService
{
@SuppressWarnings("unused")
private MaterialCategoryIDAO materialCategoryDao;
public void setMaterialCategoryDao(MaterialCategoryIDAO materialCategoryDao) {
this.materialCategoryDao = materialCategoryDao;
}
@Override
protected Class<MaterialCategory> getEntityClass()
{
return MaterialCategory.class;
}
}
package com.jsh.service.materials;
import com.jsh.base.BaseIService;
import com.jsh.model.po.Material;
public interface MaterialIService extends BaseIService<Material>
{
}
package com.jsh.service.materials;
import com.jsh.base.BaseService;
import com.jsh.dao.materials.MaterialIDAO;
import com.jsh.model.po.Material;
public class MaterialService extends BaseService<Material> implements MaterialIService
{
@SuppressWarnings("unused")
private MaterialIDAO materialDao;
public void setMaterialDao(MaterialIDAO materialDao) {
this.materialDao = materialDao;
}
@Override
protected Class<Material> getEntityClass()
{
return Material.class;
}
}
package com.jsh.service.materials;
import com.jsh.base.BaseIService;
import com.jsh.model.po.Person;
public interface PersonIService extends BaseIService<Person>
{
}
package com.jsh.service.materials;
import com.jsh.base.BaseService;
import com.jsh.dao.materials.PersonIDAO;
import com.jsh.model.po.Person;
public class PersonService extends BaseService<Person> implements PersonIService
{
@SuppressWarnings("unused")
private PersonIDAO personDao;
public void setPersonDao(PersonIDAO personDao) {
this.personDao = personDao;
}
@Override
protected Class<Person> getEntityClass()
{
return Person.class;
}
}
package com.jsh.util;
/**
* 定义资产管理常量
* @author jishenghua
*/
public interface AssetConstants
{
/**
* 公共常量
* @author jishenghua
*/
public class Common
{
}
/**
* 资产常量--导入导出excel表格业务相关
* @author jishenghua
*/
public class BusinessForExcel
{
/**
* 资产名称常量
*/
public static final int EXCEL_ASSETNAME = 0;
/**
* 资产类型常量
*/
public static final int EXCEL_CATEGORY = 1;
/**
* 资产单价
*/
public static final int EXCEL_PRICE = 2;
/**
* 用户
*/
public static final int EXCEL_USER = 3;
/**
* 购买日期
*/
public static final int EXCEL_PURCHASE_DATE = 4;
/**
* 资产状态
*/
public static final int EXCEL_STATUS = 5;
/**
* 位置
*/
public static final int EXCEL_LOCATION = 6;
/**
* 资产编号
*/
public static final int EXCEL_NUM = 7;
/**
* 序列号
*/
public static final int EXCEL_SERIALNO = 8;
/**
* 有效日期
*/
public static final int EXCEL_EXPIRATION_DATE = 9;
/**
* 保修日期
*/
public static final int EXCEL_WARRANTY_DATE = 10;
/**
* 供应商
*/
public static final int EXCEL_SUPPLIER = 11;
/**
* 标签
*/
public static final int EXCEL_LABLE = 12;
/**
* 描述
*/
public static final int EXCEL_DESC = 13;
/**
* 表头
*/
public static final int EXCEL_TABLE_HEAD = 0;
/**
* 状态 --在库
*/
public static final int EXCEl_STATUS_ZAIKU = 0;
/**
* 状态 --在用
*/
public static final int EXCEl_STATUS_INUSE = 1;
/**
* 状态 -- 消费
*/
public static final int EXCEl_STATUS_CONSUME = 2;
/**
* action返回excel结果
*/
public static final String EXCEL = "excel";
}
}
package com.jsh.util;
import java.util.HashMap;
import java.util.Map;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
/**
* 获取spring配置中的bean对象,是单例,只会加载一次,请注意使用
* 注意:此工具类默认处理UI组件WEB-INF目录下的applicationContext.xml配置文件,请注意文件 名和路径
* @author jishenghua
* @qq 7 5 2 7 1 8 9 2 0
* @version V1.0
*/
public class BeanFactoryUtil
{
private static BeanFactoryUtil defaultBeanFactory;
private ApplicationContext defaultAC = null;
//private ApplicationContext autoLoadAC = null;
private static BeanFactoryUtil specialBeanFactory;
private ApplicationContext specialAC = null;
private static Map<String, ApplicationContext> beanMap = new HashMap<String, ApplicationContext>();
//private Logger log = Logger.getLogger(BeanFactoryUtil.class);
/**
* 私有构造函数,默认为UI组件WEB-INF目录下的applicationContext.xml配置文件
*/
private BeanFactoryUtil()
{
String fileUrl = PathTool.getWebinfPath();
//这里只对UI组件WEB-INF目录下的applicationContext.xml配置文件
defaultAC = new FileSystemXmlApplicationContext( new
String[]{fileUrl
+ "spring/basic-applicationContext.xml",
fileUrl + "spring/dao-applicationContext.xml"});
}
/**
* 私有构造函数,带有文件的classpath路径,可能是非applicationContext.xml文件
*/
private BeanFactoryUtil(String fileClassPath)
{
specialAC = new ClassPathXmlApplicationContext("classpath:"
+ fileClassPath);
}
/**
* 非web.xml方式加载spring配置文件方式的实体实例获取方式
* @param fileClassPath
* @param beanName
* @return
*/
public synchronized static Object getBeanByClassPathAndBeanName(
String fileClassPath, String beanName)
{
ApplicationContext ac = beanMap.get(fileClassPath);
if (null == ac)
{
ac = new ClassPathXmlApplicationContext("classpath:"
+ fileClassPath);
beanMap.put(fileClassPath, ac);
}
return ac.getBean(beanName);
}
/**
* 获取类实例
* 默认加载UI组件WEB-INF目录下的applicationContext.xml配置文件
* @return
*
*/
public synchronized static BeanFactoryUtil getInstance()
{
if (null == defaultBeanFactory)
{
defaultBeanFactory = new BeanFactoryUtil();
}
return defaultBeanFactory;
}
/**
* 获取类实例,这种情况一定是在依赖其他组件时没有在applicationContext.xml加载器spring文件时使用
* 这种情况请少用
* @param fileClassPath
* @return
*/
@Deprecated
public synchronized static BeanFactoryUtil getInstance(String fileClassPath)
{
if (null == specialBeanFactory)
{
specialBeanFactory = new BeanFactoryUtil(fileClassPath);
}
return specialBeanFactory;
}
/**
* 获取UI组件WEB-INF目录下的applicationContext.xml配置文件中配置的bean实例
* @param beanName
* @return
*/
public Object getBean(String beanName)
{
return defaultAC.getBean(beanName);
}
/**
* 获取没有在applicationContext.xml配置文件中引入的spring配置文件,即没有用容器加载过的配置文件
* 这里为特殊情况下使用,不推荐使用
* 推荐在applicationContext.xml配置文件中引入需要使用的spring配置文件,然后使用BeanFactoryUtil.getInstance().getBean("")方法
* @param beanName
* @return
*/
@Deprecated
public Object getSpecialBean(String beanName)
{
return specialAC.getBean(beanName);
}
}
package com.jsh.util;
public interface ExceptionCodeConstants
{
/**
* 用户错误码定义
*/
public class UserExceptionCode
{
/**
* 用户不存在
*/
public static final int USER_NOT_EXIST = 1;
/**
* 用户密码错误
*/
public static final int USER_PASSWORD_ERROR = 2;
/**
* 被加入黑名单
*/
public static final int BLACK_USER = 3;
/**
* 可以登录
*/
public static final int USER_CONDITION_FIT = 4;
/**
* 访问数据库异常
*/
public static final int USER_ACCESS_EXCEPTION = 5;
}
}
package com.jsh.util;
public interface JshConstants
{
/**
* 定义资产管理公共常量
* @author jishenghua
*/
public class Common
{
/**
* Info级别日志前缀
*/
public static final String LOG_INFO_PREFIX = "==========";
/**
* error级别日志前缀
*/
public static final String LOG_ERROR_PREFIX = ">>>>>>>>>>";
/**
* debug级别日志前缀
*/
public static final String LOG_DEBUG_PREFIX = "-----------";
/**
* fatal级别日志前缀
*/
public static final String LOG_FATAL_PREFIX = "$$$$$$$$$$";
/**
* warn级别日志前缀
*/
public static final String LOG_WARN_PREFIX = "##########";
}
}
package com.jsh.util;
/**
* @title: 平台异常基类
* @description: 用于包装一些异常信息,打印日志等服务
* @author jishenghua
* @qq 7 5 2 7 1 8 9 2 0
* @since: 2014-02-24
*/
@SuppressWarnings("serial")
public class JshException extends Exception
{
public long errorCode = -1;
public String message ;
public JshException()
{
super();
}
public JshException(String message)
{
super(message);
this.message = message;
}
public JshException(String message, Throwable cause)
{
super(message, cause);
this.message = message;
}
public JshException(Throwable cause)
{
super(cause);
}
public JshException(long errorCode)
{
super();
this.errorCode = errorCode;
}
public JshException(String message, long errorCode)
{
super(message);
this.errorCode = errorCode;
this.message = message;
}
public JshException(String message, long errorCode, Throwable cause)
{
super(message, cause);
this.errorCode = errorCode;
this.message = message;
}
public JshException(long errorCode, Throwable cause)
{
super(cause);
this.errorCode = errorCode;
}
public long getErrorCode()
{
return errorCode;
}
public String getMessage()
{
return message;
}
}
package com.jsh.util;
import org.hibernate.FlushMode;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.orm.hibernate3.support.OpenSessionInViewFilter;
public class OpenSessionInViewFilterExtend extends OpenSessionInViewFilter
{
@Override
protected Session getSession(SessionFactory sessionFactory)
throws DataAccessResourceFailureException
{
this.setFlushMode(FlushMode.AUTO);
return super.getSession(sessionFactory);
}
@Override
protected void closeSession(Session session, SessionFactory sessionFactory)
{
session.flush();
super.closeSession(session, sessionFactory);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment