整理代码

This commit is contained in:
季圣华 2016-11-19 23:32:00 -06:00
parent 46b75fecc6
commit 55135acaaa
76 changed files with 6878 additions and 6884 deletions

View File

@ -18,7 +18,7 @@
</column>
</property>
<property name="password" type="java.lang.String">
<column name="password" length="30" not-null="true">
<column name="password" length="50" not-null="true">
<comment>登陆密码</comment>
</column>
</property>

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -1,120 +1,120 @@
package com.jsh.action.asset;
import java.util.HashMap;
import java.util.Map;
import com.jsh.base.BaseAction;
import com.jsh.base.Log;
import com.jsh.exception.AmsException;
import com.jsh.model.po.Asset;
import com.jsh.model.vo.asset.ReportModel;
import com.jsh.service.asset.ReportIService;
import com.jsh.util.common.PageUtil;
@SuppressWarnings("serial")
public class ReportAction extends BaseAction<ReportModel>
{
private ReportModel model = new ReportModel();
private ReportIService reportService;
/**
* 查找资产信息
* @return
*/
public String find()
{
try
{
PageUtil<Asset> pageUtil = new PageUtil<Asset>();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
pageUtil.setAdvSearch(getCondition());
String reportType = getReportType(new HashMap<String,Object>());
reportService.find(pageUtil,reportType.split("_")[0],reportType.split("_")[1]);
model.getShowModel().setReportData(pageUtil.getPageList());
}
catch (AmsException e)
{
Log.errorFileSync(">>>>>>>>>查找资产信息异常", e);
model.getShowModel().setMsgTip("get report data exception");
}
return SUCCESS;
}
/**
* 拼接搜索条件
* @return
*/
private Map<String,Object> getCondition()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("assetname.id_n_eq", model.getAssetNameID());
condition.put("assetname.category.id_n_eq", model.getAssetCategoryID());
condition.put("user.id_n_eq", model.getUsernameID());
condition.put("status_n_eq", model.getStatus());
condition.put("supplier.id_n_eq", model.getSupplierID());
condition.put("dataSum_s_order","desc");
//拼接统计数据条件
getReportType(condition);
return condition;
}
/**
* 获取统计条件
* @param condition
*/
private String getReportType(Map<String,Object> condition)
{
// <option value="0">资产状态</option>
// <option value="1">资产类型</option>
// <option value="2">供应商</option>
// <option value="3">资产名称</option>
// <option value="4">所属用户</option>
int reportType = model.getReportType();
String reportTypeInfo = "";
String reportTypeName = "";
switch(reportType)
{
case 0:
condition.put("status_s_gb", "group");
reportTypeInfo = "status";
reportTypeName = "status";
break;
case 1:
condition.put("assetname.category.id_s_gb", "group");
reportTypeInfo = "assetname.category.id";
reportTypeName = "assetname.category.assetname";
break;
case 2:
condition.put("supplier.id_s_gb", "group");
reportTypeInfo = "supplier.id";
reportTypeName = "supplier.supplier";
break;
case 3:
condition.put("assetname.id_s_gb", "group");
reportTypeInfo = "assetname.id";
reportTypeName = "assetname.assetname";
break;
case 4:
condition.put("user.id_s_gb", "group");
reportTypeInfo = "user.id";
reportTypeName = "user.username";
break;
}
return reportTypeInfo + "_" + reportTypeName;
}
//=========Spring注入以及model驱动公共方法===========
public void setReportService(ReportIService reportService)
{
this.reportService = reportService;
}
@Override
public ReportModel getModel()
{
return model;
}
}
package com.jsh.action.asset;
import java.util.HashMap;
import java.util.Map;
import com.jsh.base.BaseAction;
import com.jsh.base.Log;
import com.jsh.exception.JshException;
import com.jsh.model.po.Asset;
import com.jsh.model.vo.asset.ReportModel;
import com.jsh.service.asset.ReportIService;
import com.jsh.util.common.PageUtil;
@SuppressWarnings("serial")
public class ReportAction extends BaseAction<ReportModel>
{
private ReportModel model = new ReportModel();
private ReportIService reportService;
/**
* 查找资产信息
* @return
*/
public String find()
{
try
{
PageUtil<Asset> pageUtil = new PageUtil<Asset>();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
pageUtil.setAdvSearch(getCondition());
String reportType = getReportType(new HashMap<String,Object>());
reportService.find(pageUtil,reportType.split("_")[0],reportType.split("_")[1]);
model.getShowModel().setReportData(pageUtil.getPageList());
}
catch (JshException e)
{
Log.errorFileSync(">>>>>>>>>查找资产信息异常", e);
model.getShowModel().setMsgTip("get report data exception");
}
return SUCCESS;
}
/**
* 拼接搜索条件
* @return
*/
private Map<String,Object> getCondition()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("assetname.id_n_eq", model.getAssetNameID());
condition.put("assetname.category.id_n_eq", model.getAssetCategoryID());
condition.put("user.id_n_eq", model.getUsernameID());
condition.put("status_n_eq", model.getStatus());
condition.put("supplier.id_n_eq", model.getSupplierID());
condition.put("dataSum_s_order","desc");
//拼接统计数据条件
getReportType(condition);
return condition;
}
/**
* 获取统计条件
* @param condition
*/
private String getReportType(Map<String,Object> condition)
{
// <option value="0">资产状态</option>
// <option value="1">资产类型</option>
// <option value="2">供应商</option>
// <option value="3">资产名称</option>
// <option value="4">所属用户</option>
int reportType = model.getReportType();
String reportTypeInfo = "";
String reportTypeName = "";
switch(reportType)
{
case 0:
condition.put("status_s_gb", "group");
reportTypeInfo = "status";
reportTypeName = "status";
break;
case 1:
condition.put("assetname.category.id_s_gb", "group");
reportTypeInfo = "assetname.category.id";
reportTypeName = "assetname.category.assetname";
break;
case 2:
condition.put("supplier.id_s_gb", "group");
reportTypeInfo = "supplier.id";
reportTypeName = "supplier.supplier";
break;
case 3:
condition.put("assetname.id_s_gb", "group");
reportTypeInfo = "assetname.id";
reportTypeName = "assetname.assetname";
break;
case 4:
condition.put("user.id_s_gb", "group");
reportTypeInfo = "user.id";
reportTypeName = "user.username";
break;
}
return reportTypeInfo + "_" + reportTypeName;
}
//=========Spring注入以及model驱动公共方法===========
public void setReportService(ReportIService reportService)
{
this.reportService = reportService;
}
@Override
public ReportModel getModel()
{
return model;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,380 +1,380 @@
package com.jsh.action.basic;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
import com.jsh.base.BaseAction;
import com.jsh.base.Log;
import com.jsh.exception.AmsException;
import com.jsh.model.po.Depot;
import com.jsh.model.po.Logdetails;
import com.jsh.model.po.Role;
import com.jsh.model.vo.basic.DepotModel;
import com.jsh.service.basic.DepotIService;
import com.jsh.service.basic.UserBusinessIService;
import com.jsh.util.common.PageUtil;
@SuppressWarnings("serial")
public class DepotAction extends BaseAction<DepotModel>
{
private DepotIService depotService;
private UserBusinessIService userBusinessService;
private DepotModel model = new DepotModel();
@SuppressWarnings({ "rawtypes", "unchecked" })
public String getBasicData()
{
Map<String,List> mapData = model.getShowModel().getMap();
PageUtil pageUtil = new PageUtil();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
try
{
Map<String,Object> condition = pageUtil.getAdvSearch();
condition.put("id_s_order", "asc");
depotService.find(pageUtil);
mapData.put("depotList", pageUtil.getPageList());
}
catch (Exception e)
{
Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e);
model.getShowModel().setMsgTip("exceptoin");
}
return SUCCESS;
}
/**
* 增加仓库
* @return
*/
public void create()
{
Log.infoFileSync("==================开始调用增加仓库信息方法create()===================");
Boolean flag = false;
try
{
Depot depot = new Depot();
depot.setName(model.getName());
depot.setSort(model.getSort());
depot.setRemark(model.getRemark());
depotService.create(depot);
//========标识位===========
flag = true;
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加仓库信息异常", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>增加仓库信息回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "增加仓库", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "增加仓库名称为 "+ model.getName() + " " + tipMsg + "", "增加仓库" + tipMsg));
Log.infoFileSync("==================结束调用增加仓库方法create()===================");
}
/**
* 删除仓库
* @return
*/
public String delete()
{
Log.infoFileSync("====================开始调用删除仓库信息方法delete()================");
try
{
depotService.delete(model.getDepotID());
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getDepotID() + " 的仓库异常", e);
tipMsg = "失败";
tipType = 1;
}
model.getShowModel().setMsgTip(tipMsg);
logService.create(new Logdetails(getUser(), "删除仓库", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "删除仓库ID为 "+ model.getDepotID() + " " + tipMsg + "", "删除仓库" + tipMsg));
Log.infoFileSync("====================结束调用删除仓库信息方法delete()================");
return SUCCESS;
}
/**
* 更新仓库
* @return
*/
public void update()
{
Boolean flag = false;
try
{
Depot depot = depotService.get(model.getDepotID());
depot.setName(model.getName());
depot.setSort(model.getSort());
depot.setRemark(model.getRemark());
depotService.update(depot);
flag = true;
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>修改仓库ID为 " + model.getDepotID() + "信息失败", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>修改仓库回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "更新仓库", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "更新仓库ID为 "+ model.getDepotID() + " " + tipMsg + "", "更新仓库" + tipMsg));
}
/**
* 批量删除指定ID仓库
* @return
*/
public String batchDelete()
{
try
{
depotService.batchDelete(model.getDepotIDs());
model.getShowModel().setMsgTip("成功");
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>批量删除仓库ID为" + model.getDepotIDs() + "信息异常", e);
tipMsg = "失败";
tipType = 1;
}
logService.create(new Logdetails(getUser(), "批量删除仓库", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "批量删除仓库ID为 "+ model.getDepotIDs() + " " + tipMsg + "", "批量删除仓库" + tipMsg));
return SUCCESS;
}
/**
* 检查输入名称是否存在
*/
public void checkIsNameExist()
{
Boolean flag = false;
try
{
flag = depotService.checkIsNameExist("name",model.getName(),"id", model.getDepotID());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查仓库名称为:" + model.getName() + " ID为 " + model.getDepotID() + " 是否存在异常!");
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>回写检查仓库名称为:" + model.getName() + " ID为 " + model.getDepotID() + " 是否存在异常!",e);
}
}
}
/**
* 查找仓库信息
* @return
*/
public void findBy()
{
try
{
PageUtil<Depot> pageUtil = new PageUtil<Depot>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition());
depotService.find(pageUtil);
List<Depot> dataList = pageUtil.getPageList();
//开始拼接json数据
// {"total":28,"rows":[
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
// ]}
JSONObject outer = new JSONObject();
outer.put("total", pageUtil.getTotalCount());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(Depot depot:dataList)
{
JSONObject item = new JSONObject();
item.put("id", depot.getId());
//供应商名称
item.put("name", depot.getName());
item.put("sort", depot.getSort());
item.put("remark", depot.getRemark());
item.put("op", 1);
dataArray.add(item);
}
}
outer.put("rows", dataArray);
//回写查询结果
toClient(outer.toString());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓库信息异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓库信息结果异常", e);
}
}
/**
* 用户对应部门显示
* @return
*/
public void findUserDepot()
{
try
{
PageUtil<Depot> pageUtil = new PageUtil<Depot>();
pageUtil.setPageSize(100);
//pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition_UserDepot());
depotService.find(pageUtil);
List<Depot> dataList = pageUtil.getPageList();
//开始拼接json数据
JSONObject outer = new JSONObject();
outer.put("id", 1);
outer.put("text", "部门列表");
outer.put("state", "open");
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(Depot depot:dataList)
{
JSONObject item = new JSONObject();
item.put("id", depot.getId());
item.put("text", depot.getName());
//勾选判断1
Boolean flag = false;
try
{
flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+depot.getId().toString()+"]");
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>设置用户对应的部门:类型" + model.getUBType() + " KeyId为 " + model.getUBKeyId() + " 存在异常!");
}
if (flag==true){item.put("checked", true);}
//结束
dataArray.add(item);
}
}
outer.put("children", dataArray);
//回写查询结果
toClient("["+outer.toString()+"]");
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找部门异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询部门结果异常", e);
}
}
/**
* 拼接搜索条件
* @return
*/
private Map<String,Object> getCondition()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("name_s_like", model.getName());
condition.put("remark_s_like", model.getRemark());
condition.put("sort_s_order", "asc");
return condition;
}
/**
* 拼接搜索条件-用户对应部门
* @return
*/
private Map<String,Object> getCondition_UserDepot()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("Id_s_order", "asc");
return condition;
}
//=============以下spring注入以及Model驱动公共方法与Action处理无关==================
@Override
public DepotModel getModel()
{
return model;
}
public void setDepotService(DepotIService depotService)
{
this.depotService = depotService;
}
public void setUserBusinessService(UserBusinessIService userBusinessService) {
this.userBusinessService = userBusinessService;
}
}
package com.jsh.action.basic;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
import com.jsh.base.BaseAction;
import com.jsh.base.Log;
import com.jsh.exception.JshException;
import com.jsh.model.po.Depot;
import com.jsh.model.po.Logdetails;
import com.jsh.model.po.Role;
import com.jsh.model.vo.basic.DepotModel;
import com.jsh.service.basic.DepotIService;
import com.jsh.service.basic.UserBusinessIService;
import com.jsh.util.common.PageUtil;
@SuppressWarnings("serial")
public class DepotAction extends BaseAction<DepotModel>
{
private DepotIService depotService;
private UserBusinessIService userBusinessService;
private DepotModel model = new DepotModel();
@SuppressWarnings({ "rawtypes", "unchecked" })
public String getBasicData()
{
Map<String,List> mapData = model.getShowModel().getMap();
PageUtil pageUtil = new PageUtil();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
try
{
Map<String,Object> condition = pageUtil.getAdvSearch();
condition.put("id_s_order", "asc");
depotService.find(pageUtil);
mapData.put("depotList", pageUtil.getPageList());
}
catch (Exception e)
{
Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e);
model.getShowModel().setMsgTip("exceptoin");
}
return SUCCESS;
}
/**
* 增加仓库
* @return
*/
public void create()
{
Log.infoFileSync("==================开始调用增加仓库信息方法create()===================");
Boolean flag = false;
try
{
Depot depot = new Depot();
depot.setName(model.getName());
depot.setSort(model.getSort());
depot.setRemark(model.getRemark());
depotService.create(depot);
//========标识位===========
flag = true;
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加仓库信息异常", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>增加仓库信息回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "增加仓库", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "增加仓库名称为 "+ model.getName() + " " + tipMsg + "", "增加仓库" + tipMsg));
Log.infoFileSync("==================结束调用增加仓库方法create()===================");
}
/**
* 删除仓库
* @return
*/
public String delete()
{
Log.infoFileSync("====================开始调用删除仓库信息方法delete()================");
try
{
depotService.delete(model.getDepotID());
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getDepotID() + " 的仓库异常", e);
tipMsg = "失败";
tipType = 1;
}
model.getShowModel().setMsgTip(tipMsg);
logService.create(new Logdetails(getUser(), "删除仓库", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "删除仓库ID为 "+ model.getDepotID() + " " + tipMsg + "", "删除仓库" + tipMsg));
Log.infoFileSync("====================结束调用删除仓库信息方法delete()================");
return SUCCESS;
}
/**
* 更新仓库
* @return
*/
public void update()
{
Boolean flag = false;
try
{
Depot depot = depotService.get(model.getDepotID());
depot.setName(model.getName());
depot.setSort(model.getSort());
depot.setRemark(model.getRemark());
depotService.update(depot);
flag = true;
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>修改仓库ID为 " + model.getDepotID() + "信息失败", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>修改仓库回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "更新仓库", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "更新仓库ID为 "+ model.getDepotID() + " " + tipMsg + "", "更新仓库" + tipMsg));
}
/**
* 批量删除指定ID仓库
* @return
*/
public String batchDelete()
{
try
{
depotService.batchDelete(model.getDepotIDs());
model.getShowModel().setMsgTip("成功");
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>批量删除仓库ID为" + model.getDepotIDs() + "信息异常", e);
tipMsg = "失败";
tipType = 1;
}
logService.create(new Logdetails(getUser(), "批量删除仓库", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "批量删除仓库ID为 "+ model.getDepotIDs() + " " + tipMsg + "", "批量删除仓库" + tipMsg));
return SUCCESS;
}
/**
* 检查输入名称是否存在
*/
public void checkIsNameExist()
{
Boolean flag = false;
try
{
flag = depotService.checkIsNameExist("name",model.getName(),"id", model.getDepotID());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查仓库名称为:" + model.getName() + " ID为 " + model.getDepotID() + " 是否存在异常!");
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>回写检查仓库名称为:" + model.getName() + " ID为 " + model.getDepotID() + " 是否存在异常!",e);
}
}
}
/**
* 查找仓库信息
* @return
*/
public void findBy()
{
try
{
PageUtil<Depot> pageUtil = new PageUtil<Depot>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition());
depotService.find(pageUtil);
List<Depot> dataList = pageUtil.getPageList();
//开始拼接json数据
// {"total":28,"rows":[
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
// ]}
JSONObject outer = new JSONObject();
outer.put("total", pageUtil.getTotalCount());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(Depot depot:dataList)
{
JSONObject item = new JSONObject();
item.put("id", depot.getId());
//供应商名称
item.put("name", depot.getName());
item.put("sort", depot.getSort());
item.put("remark", depot.getRemark());
item.put("op", 1);
dataArray.add(item);
}
}
outer.put("rows", dataArray);
//回写查询结果
toClient(outer.toString());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓库信息异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓库信息结果异常", e);
}
}
/**
* 用户对应部门显示
* @return
*/
public void findUserDepot()
{
try
{
PageUtil<Depot> pageUtil = new PageUtil<Depot>();
pageUtil.setPageSize(100);
//pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition_UserDepot());
depotService.find(pageUtil);
List<Depot> dataList = pageUtil.getPageList();
//开始拼接json数据
JSONObject outer = new JSONObject();
outer.put("id", 1);
outer.put("text", "部门列表");
outer.put("state", "open");
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(Depot depot:dataList)
{
JSONObject item = new JSONObject();
item.put("id", depot.getId());
item.put("text", depot.getName());
//勾选判断1
Boolean flag = false;
try
{
flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+depot.getId().toString()+"]");
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>设置用户对应的部门:类型" + model.getUBType() + " KeyId为 " + model.getUBKeyId() + " 存在异常!");
}
if (flag==true){item.put("checked", true);}
//结束
dataArray.add(item);
}
}
outer.put("children", dataArray);
//回写查询结果
toClient("["+outer.toString()+"]");
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找部门异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询部门结果异常", e);
}
}
/**
* 拼接搜索条件
* @return
*/
private Map<String,Object> getCondition()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("name_s_like", model.getName());
condition.put("remark_s_like", model.getRemark());
condition.put("sort_s_order", "asc");
return condition;
}
/**
* 拼接搜索条件-用户对应部门
* @return
*/
private Map<String,Object> getCondition_UserDepot()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("Id_s_order", "asc");
return condition;
}
//=============以下spring注入以及Model驱动公共方法与Action处理无关==================
@Override
public DepotModel getModel()
{
return model;
}
public void setDepotService(DepotIService depotService)
{
this.depotService = depotService;
}
public void setUserBusinessService(UserBusinessIService userBusinessService) {
this.userBusinessService = userBusinessService;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,347 +1,347 @@
package com.jsh.action.basic;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
import com.jsh.base.BaseAction;
import com.jsh.base.Log;
import com.jsh.exception.AmsException;
import com.jsh.model.po.App;
import com.jsh.model.po.Role;
import com.jsh.model.po.Logdetails;
import com.jsh.model.vo.basic.RoleModel;
import com.jsh.service.basic.RoleIService;
import com.jsh.service.basic.UserBusinessIService;
import com.jsh.util.common.PageUtil;
@SuppressWarnings("serial")
public class RoleAction extends BaseAction<RoleModel>
{
private RoleIService roleService;
private UserBusinessIService userBusinessService;
private RoleModel model = new RoleModel();
/**
* 增加角色
* @return
*/
public void create()
{
Log.infoFileSync("==================开始调用增加角色信息方法create()===================");
Boolean flag = false;
try
{
Role role = new Role();
role.setName(model.getName());
roleService.create(role);
//========标识位===========
flag = true;
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加角色信息异常", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>增加角色信息回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "增加角色", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "增加角色名称为 "+ model.getName() + " " + tipMsg + "", "增加角色" + tipMsg));
Log.infoFileSync("==================结束调用增加角色方法create()===================");
}
/**
* 删除角色
* @return
*/
public String delete()
{
Log.infoFileSync("====================开始调用删除角色信息方法delete()================");
try
{
roleService.delete(model.getRoleID());
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getRoleID() + " 的角色异常", e);
tipMsg = "失败";
tipType = 1;
}
model.getShowModel().setMsgTip(tipMsg);
logService.create(new Logdetails(getUser(), "删除角色", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "删除角色ID为 "+ model.getRoleID() + " " + tipMsg + "", "删除角色" + tipMsg));
Log.infoFileSync("====================结束调用删除角色信息方法delete()================");
return SUCCESS;
}
/**
* 更新角色
* @return
*/
public void update()
{
Boolean flag = false;
try
{
Role role = roleService.get(model.getRoleID());
role.setName(model.getName());
roleService.update(role);
flag = true;
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>修改角色ID为 " + model.getRoleID() + "信息失败", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>修改角色回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "更新角色", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "更新角色ID为 "+ model.getRoleID() + " " + tipMsg + "", "更新角色" + tipMsg));
}
/**
* 批量删除指定ID角色
* @return
*/
public String batchDelete()
{
try
{
roleService.batchDelete(model.getRoleIDs());
model.getShowModel().setMsgTip("成功");
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>批量删除角色ID为" + model.getRoleIDs() + "信息异常", e);
tipMsg = "失败";
tipType = 1;
}
logService.create(new Logdetails(getUser(), "批量删除角色", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "批量删除角色ID为 "+ model.getRoleIDs() + " " + tipMsg + "", "批量删除角色" + tipMsg));
return SUCCESS;
}
/**
* 检查输入名称是否存在
*/
public void checkIsNameExist()
{
Boolean flag = false;
try
{
flag = roleService.checkIsNameExist("name",model.getName(),"Id", model.getRoleID());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查角色名称为:" + model.getName() + " ID为 " + model.getRoleID() + " 是否存在异常!");
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>回写检查角色名称为:" + model.getName() + " ID为 " + model.getRoleID() + " 是否存在异常!",e);
}
}
}
/**
* 查找角色信息
* @return
*/
public void findBy()
{
try
{
PageUtil<Role> pageUtil = new PageUtil<Role>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition());
roleService.find(pageUtil);
List<Role> dataList = pageUtil.getPageList();
//开始拼接json数据
// {"total":28,"rows":[
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
// ]}
JSONObject outer = new JSONObject();
outer.put("total", pageUtil.getTotalCount());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(Role role:dataList)
{
JSONObject item = new JSONObject();
item.put("Id", role.getId());
//供应商名称
item.put("Name", role.getName());
item.put("op", 1);
dataArray.add(item);
}
}
outer.put("rows", dataArray);
//回写查询结果
toClient(outer.toString());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找角色信息异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询角色信息结果异常", e);
}
}
/**
* 用户对应角色显示
* @return
*/
public void findUserRole()
{
try
{
PageUtil<Role> pageUtil = new PageUtil<Role>();
pageUtil.setPageSize(100);
//pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition_UserRole());
roleService.find(pageUtil);
List<Role> dataList = pageUtil.getPageList();
//开始拼接json数据
JSONObject outer = new JSONObject();
outer.put("id", 1);
outer.put("text", "角色列表");
outer.put("state", "open");
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(Role role:dataList)
{
JSONObject item = new JSONObject();
item.put("id", role.getId());
item.put("text", role.getName());
//勾选判断1
Boolean flag = false;
try
{
flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+role.getId().toString()+"]");
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>设置用户对应的角色:类型" + model.getUBType() + " KeyId为 " + model.getUBKeyId() + " 存在异常!");
}
if (flag==true){item.put("checked", true);}
//结束
dataArray.add(item);
}
}
outer.put("children", dataArray);
//回写查询结果
toClient("["+outer.toString()+"]");
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找角色异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询角色结果异常", e);
}
}
/**
* 拼接搜索条件
* @return
*/
private Map<String,Object> getCondition()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("Name_s_like", model.getName());
condition.put("Id_s_order", "asc");
return condition;
}
/**
* 拼接搜索条件-用户对应角色
* @return
*/
private Map<String,Object> getCondition_UserRole()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("Id_s_order", "asc");
return condition;
}
//=============以下spring注入以及Model驱动公共方法与Action处理无关==================
@Override
public RoleModel getModel()
{
return model;
}
public void setRoleService(RoleIService roleService)
{
this.roleService = roleService;
}
public void setUserBusinessService(UserBusinessIService userBusinessService) {
this.userBusinessService = userBusinessService;
}
}
package com.jsh.action.basic;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
import com.jsh.base.BaseAction;
import com.jsh.base.Log;
import com.jsh.exception.JshException;
import com.jsh.model.po.App;
import com.jsh.model.po.Role;
import com.jsh.model.po.Logdetails;
import com.jsh.model.vo.basic.RoleModel;
import com.jsh.service.basic.RoleIService;
import com.jsh.service.basic.UserBusinessIService;
import com.jsh.util.common.PageUtil;
@SuppressWarnings("serial")
public class RoleAction extends BaseAction<RoleModel>
{
private RoleIService roleService;
private UserBusinessIService userBusinessService;
private RoleModel model = new RoleModel();
/**
* 增加角色
* @return
*/
public void create()
{
Log.infoFileSync("==================开始调用增加角色信息方法create()===================");
Boolean flag = false;
try
{
Role role = new Role();
role.setName(model.getName());
roleService.create(role);
//========标识位===========
flag = true;
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加角色信息异常", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>增加角色信息回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "增加角色", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "增加角色名称为 "+ model.getName() + " " + tipMsg + "", "增加角色" + tipMsg));
Log.infoFileSync("==================结束调用增加角色方法create()===================");
}
/**
* 删除角色
* @return
*/
public String delete()
{
Log.infoFileSync("====================开始调用删除角色信息方法delete()================");
try
{
roleService.delete(model.getRoleID());
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getRoleID() + " 的角色异常", e);
tipMsg = "失败";
tipType = 1;
}
model.getShowModel().setMsgTip(tipMsg);
logService.create(new Logdetails(getUser(), "删除角色", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "删除角色ID为 "+ model.getRoleID() + " " + tipMsg + "", "删除角色" + tipMsg));
Log.infoFileSync("====================结束调用删除角色信息方法delete()================");
return SUCCESS;
}
/**
* 更新角色
* @return
*/
public void update()
{
Boolean flag = false;
try
{
Role role = roleService.get(model.getRoleID());
role.setName(model.getName());
roleService.update(role);
flag = true;
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>修改角色ID为 " + model.getRoleID() + "信息失败", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>修改角色回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "更新角色", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "更新角色ID为 "+ model.getRoleID() + " " + tipMsg + "", "更新角色" + tipMsg));
}
/**
* 批量删除指定ID角色
* @return
*/
public String batchDelete()
{
try
{
roleService.batchDelete(model.getRoleIDs());
model.getShowModel().setMsgTip("成功");
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>批量删除角色ID为" + model.getRoleIDs() + "信息异常", e);
tipMsg = "失败";
tipType = 1;
}
logService.create(new Logdetails(getUser(), "批量删除角色", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "批量删除角色ID为 "+ model.getRoleIDs() + " " + tipMsg + "", "批量删除角色" + tipMsg));
return SUCCESS;
}
/**
* 检查输入名称是否存在
*/
public void checkIsNameExist()
{
Boolean flag = false;
try
{
flag = roleService.checkIsNameExist("name",model.getName(),"Id", model.getRoleID());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查角色名称为:" + model.getName() + " ID为 " + model.getRoleID() + " 是否存在异常!");
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>回写检查角色名称为:" + model.getName() + " ID为 " + model.getRoleID() + " 是否存在异常!",e);
}
}
}
/**
* 查找角色信息
* @return
*/
public void findBy()
{
try
{
PageUtil<Role> pageUtil = new PageUtil<Role>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition());
roleService.find(pageUtil);
List<Role> dataList = pageUtil.getPageList();
//开始拼接json数据
// {"total":28,"rows":[
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
// ]}
JSONObject outer = new JSONObject();
outer.put("total", pageUtil.getTotalCount());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(Role role:dataList)
{
JSONObject item = new JSONObject();
item.put("Id", role.getId());
//供应商名称
item.put("Name", role.getName());
item.put("op", 1);
dataArray.add(item);
}
}
outer.put("rows", dataArray);
//回写查询结果
toClient(outer.toString());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找角色信息异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询角色信息结果异常", e);
}
}
/**
* 用户对应角色显示
* @return
*/
public void findUserRole()
{
try
{
PageUtil<Role> pageUtil = new PageUtil<Role>();
pageUtil.setPageSize(100);
//pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition_UserRole());
roleService.find(pageUtil);
List<Role> dataList = pageUtil.getPageList();
//开始拼接json数据
JSONObject outer = new JSONObject();
outer.put("id", 1);
outer.put("text", "角色列表");
outer.put("state", "open");
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(Role role:dataList)
{
JSONObject item = new JSONObject();
item.put("id", role.getId());
item.put("text", role.getName());
//勾选判断1
Boolean flag = false;
try
{
flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+role.getId().toString()+"]");
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>设置用户对应的角色:类型" + model.getUBType() + " KeyId为 " + model.getUBKeyId() + " 存在异常!");
}
if (flag==true){item.put("checked", true);}
//结束
dataArray.add(item);
}
}
outer.put("children", dataArray);
//回写查询结果
toClient("["+outer.toString()+"]");
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找角色异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询角色结果异常", e);
}
}
/**
* 拼接搜索条件
* @return
*/
private Map<String,Object> getCondition()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("Name_s_like", model.getName());
condition.put("Id_s_order", "asc");
return condition;
}
/**
* 拼接搜索条件-用户对应角色
* @return
*/
private Map<String,Object> getCondition_UserRole()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("Id_s_order", "asc");
return condition;
}
//=============以下spring注入以及Model驱动公共方法与Action处理无关==================
@Override
public RoleModel getModel()
{
return model;
}
public void setRoleService(RoleIService roleService)
{
this.roleService = roleService;
}
public void setUserBusinessService(UserBusinessIService userBusinessService) {
this.userBusinessService = userBusinessService;
}
}

View File

@ -41,6 +41,7 @@ public class UserAction extends BaseAction<UserModel>
try
{
password = Tools.md5Encryp(password);
System.out.println(password);
}
catch (NoSuchAlgorithmException e)
{
@ -136,7 +137,7 @@ public class UserAction extends BaseAction<UserModel>
user.setIsystem((short)1);
user.setIsmanager((short)1);
user.setLoginame(model.getLoginame());
String password ="00000000";
String password ="123456";
//因密码用MD5加密需要对密码进行转化
try
{

View File

@ -1,277 +1,277 @@
package com.jsh.action.materials;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
import com.jsh.base.BaseAction;
import com.jsh.base.Log;
import com.jsh.model.po.Depot;
import com.jsh.model.po.Building;
import com.jsh.model.po.Logdetails;
import com.jsh.model.vo.materials.BuildingModel;
import com.jsh.service.materials.BuildingIService;
import com.jsh.util.common.PageUtil;
@SuppressWarnings("serial")
public class BuildingAction extends BaseAction<BuildingModel>
{
private BuildingIService buildingService;
private BuildingModel model = new BuildingModel();
@SuppressWarnings({ "rawtypes", "unchecked" })
public String getBasicData()
{
Map<String,List> mapData = model.getShowModel().getMap();
PageUtil pageUtil = new PageUtil();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
try
{
Map<String,Object> condition = pageUtil.getAdvSearch();
condition.put("ProjectId_n_eq", model.getProjectId());
condition.put("Id_s_order", "asc");
buildingService.find(pageUtil);
mapData.put("buildingList", pageUtil.getPageList());
}
catch (Exception e)
{
Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e);
model.getShowModel().setMsgTip("exceptoin");
}
return SUCCESS;
}
/**
* 增加单元
* @return
*/
public void create()
{
Log.infoFileSync("==================开始调用增加单元信息方法create()===================");
Boolean flag = false;
try
{
Building building = new Building();
building.setDepot(new Depot(model.getProjectId()));
building.setName(model.getName());
building.setRemark(model.getRemark());
building.setEnabled(model.getEnabled());
buildingService.create(building);
//========标识位===========
flag = true;
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加单元信息异常", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>增加单元信息回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "增加单元", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "增加单元名称为 "+ model.getName() + " " + tipMsg + "", "增加单元" + tipMsg));
Log.infoFileSync("==================结束调用增加单元方法create()===================");
}
/**
* 删除单元
* @return
*/
public String delete()
{
Log.infoFileSync("====================开始调用删除单元信息方法delete()================");
try
{
buildingService.delete(model.getBuildingID());
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getBuildingID() + " 的单元异常", e);
tipMsg = "失败";
tipType = 1;
}
model.getShowModel().setMsgTip(tipMsg);
logService.create(new Logdetails(getUser(), "删除单元", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "删除单元ID为 "+ model.getBuildingID() + " " + tipMsg + "", "删除单元" + tipMsg));
Log.infoFileSync("====================结束调用删除单元信息方法delete()================");
return SUCCESS;
}
/**
* 更新单元
* @return
*/
public void update()
{
Boolean flag = false;
try
{
Building building = buildingService.get(model.getBuildingID());
building.setDepot(new Depot(model.getProjectId()));
building.setName(model.getName());
building.setRemark(model.getRemark());
building.setEnabled(model.getEnabled());
buildingService.update(building);
flag = true;
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>修改单元ID为 " + model.getBuildingID() + "信息失败", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>修改单元回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "更新单元", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "更新单元ID为 "+ model.getBuildingID() + " " + tipMsg + "", "更新单元" + tipMsg));
}
/**
* 批量删除指定ID单元
* @return
*/
public String batchDelete()
{
try
{
buildingService.batchDelete(model.getBuildingIDs());
model.getShowModel().setMsgTip("成功");
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>批量删除单元ID为" + model.getBuildingIDs() + "信息异常", e);
tipMsg = "失败";
tipType = 1;
}
logService.create(new Logdetails(getUser(), "批量删除单元", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "批量删除单元ID为 "+ model.getBuildingIDs() + " " + tipMsg + "", "批量删除单元" + tipMsg));
return SUCCESS;
}
/**
* 查找单元信息
* @return
*/
public void findBy()
{
try
{
PageUtil<Building> pageUtil = new PageUtil<Building>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition());
buildingService.find(pageUtil);
List<Building> dataList = pageUtil.getPageList();
//开始拼接json数据
// {"total":28,"rows":[
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
// ]}
JSONObject outer = new JSONObject();
outer.put("total", pageUtil.getTotalCount());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(Building building:dataList)
{
JSONObject item = new JSONObject();
item.put("Id", building.getId());
item.put("ProjectId", building.getDepot().getId());
item.put("ProjectName", building.getDepot().getName());
item.put("Name", building.getName());
item.put("Remark", building.getRemark());
item.put("Enabled", building.getEnabled());
item.put("op", 1);
dataArray.add(item);
}
}
outer.put("rows", dataArray);
//回写查询结果
toClient(outer.toString());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找单元信息异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询单元信息结果异常", e);
}
}
/**
* 拼接搜索条件
* @return
*/
private Map<String,Object> getCondition()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("ProjectId_n_eq", model.getProjectId());
condition.put("Name_s_like", model.getName());
condition.put("Id_s_order", "asc");
return condition;
}
//=============以下spring注入以及Model驱动公共方法与Action处理无关==================
@Override
public BuildingModel getModel()
{
return model;
}
public void setBuildingService(BuildingIService buildingService)
{
this.buildingService = buildingService;
}
}
package com.jsh.action.materials;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
import com.jsh.base.BaseAction;
import com.jsh.base.Log;
import com.jsh.model.po.Depot;
import com.jsh.model.po.Building;
import com.jsh.model.po.Logdetails;
import com.jsh.model.vo.materials.BuildingModel;
import com.jsh.service.materials.BuildingIService;
import com.jsh.util.common.PageUtil;
@SuppressWarnings("serial")
public class BuildingAction extends BaseAction<BuildingModel>
{
private BuildingIService buildingService;
private BuildingModel model = new BuildingModel();
@SuppressWarnings({ "rawtypes", "unchecked" })
public String getBasicData()
{
Map<String,List> mapData = model.getShowModel().getMap();
PageUtil pageUtil = new PageUtil();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
try
{
Map<String,Object> condition = pageUtil.getAdvSearch();
condition.put("ProjectId_n_eq", model.getProjectId());
condition.put("Id_s_order", "asc");
buildingService.find(pageUtil);
mapData.put("buildingList", pageUtil.getPageList());
}
catch (Exception e)
{
Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e);
model.getShowModel().setMsgTip("exceptoin");
}
return SUCCESS;
}
/**
* 增加单元
* @return
*/
public void create()
{
Log.infoFileSync("==================开始调用增加单元信息方法create()===================");
Boolean flag = false;
try
{
Building building = new Building();
building.setDepot(new Depot(model.getProjectId()));
building.setName(model.getName());
building.setRemark(model.getRemark());
building.setEnabled(model.getEnabled());
buildingService.create(building);
//========标识位===========
flag = true;
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加单元信息异常", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>增加单元信息回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "增加单元", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "增加单元名称为 "+ model.getName() + " " + tipMsg + "", "增加单元" + tipMsg));
Log.infoFileSync("==================结束调用增加单元方法create()===================");
}
/**
* 删除单元
* @return
*/
public String delete()
{
Log.infoFileSync("====================开始调用删除单元信息方法delete()================");
try
{
buildingService.delete(model.getBuildingID());
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getBuildingID() + " 的单元异常", e);
tipMsg = "失败";
tipType = 1;
}
model.getShowModel().setMsgTip(tipMsg);
logService.create(new Logdetails(getUser(), "删除单元", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "删除单元ID为 "+ model.getBuildingID() + " " + tipMsg + "", "删除单元" + tipMsg));
Log.infoFileSync("====================结束调用删除单元信息方法delete()================");
return SUCCESS;
}
/**
* 更新单元
* @return
*/
public void update()
{
Boolean flag = false;
try
{
Building building = buildingService.get(model.getBuildingID());
building.setDepot(new Depot(model.getProjectId()));
building.setName(model.getName());
building.setRemark(model.getRemark());
building.setEnabled(model.getEnabled());
buildingService.update(building);
flag = true;
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>修改单元ID为 " + model.getBuildingID() + "信息失败", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>修改单元回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "更新单元", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "更新单元ID为 "+ model.getBuildingID() + " " + tipMsg + "", "更新单元" + tipMsg));
}
/**
* 批量删除指定ID单元
* @return
*/
public String batchDelete()
{
try
{
buildingService.batchDelete(model.getBuildingIDs());
model.getShowModel().setMsgTip("成功");
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>批量删除单元ID为" + model.getBuildingIDs() + "信息异常", e);
tipMsg = "失败";
tipType = 1;
}
logService.create(new Logdetails(getUser(), "批量删除单元", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "批量删除单元ID为 "+ model.getBuildingIDs() + " " + tipMsg + "", "批量删除单元" + tipMsg));
return SUCCESS;
}
/**
* 查找单元信息
* @return
*/
public void findBy()
{
try
{
PageUtil<Building> pageUtil = new PageUtil<Building>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition());
buildingService.find(pageUtil);
List<Building> dataList = pageUtil.getPageList();
//开始拼接json数据
// {"total":28,"rows":[
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
// ]}
JSONObject outer = new JSONObject();
outer.put("total", pageUtil.getTotalCount());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(Building building:dataList)
{
JSONObject item = new JSONObject();
item.put("Id", building.getId());
item.put("ProjectId", building.getDepot().getId());
item.put("ProjectName", building.getDepot().getName());
item.put("Name", building.getName());
item.put("Remark", building.getRemark());
item.put("Enabled", building.getEnabled());
item.put("op", 1);
dataArray.add(item);
}
}
outer.put("rows", dataArray);
//回写查询结果
toClient(outer.toString());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找单元信息异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询单元信息结果异常", e);
}
}
/**
* 拼接搜索条件
* @return
*/
private Map<String,Object> getCondition()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("ProjectId_n_eq", model.getProjectId());
condition.put("Name_s_like", model.getName());
condition.put("Id_s_order", "asc");
return condition;
}
//=============以下spring注入以及Model驱动公共方法与Action处理无关==================
@Override
public BuildingModel getModel()
{
return model;
}
public void setBuildingService(BuildingIService buildingService)
{
this.buildingService = buildingService;
}
}

View File

@ -1,395 +1,395 @@
package com.jsh.action.materials;
import java.io.File;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
import com.jsh.base.BaseAction;
import com.jsh.base.Log;
import com.jsh.constants.asset.AssetConstants;
import com.jsh.exception.AmsException;
import com.jsh.model.po.Asset;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.DepotItem;
import com.jsh.model.po.Logdetails;
import com.jsh.model.po.Material;
import com.jsh.model.vo.materials.DepotItemModel;
import com.jsh.service.materials.DepotHeadIService;
import com.jsh.service.materials.DepotItemIService;
import com.jsh.util.common.PageUtil;
import com.jsh.util.common.Tools;
@SuppressWarnings("serial")
public class DepotItemAction extends BaseAction<DepotItemModel>
{
private DepotItemIService depotItemService;
private DepotItemModel model = new DepotItemModel();
/**
* action返回excel结果
*/
public static final String EXCEL = "excel";
/**
* 保存明细
* @return
*/
public void saveDetials()
{
Log.infoFileSync("==================开始调用保存仓管通明细信息方法saveDetials()===================");
Boolean flag = false;
try
{
Long headerId=model.getHeaderId();
String inserted=model.getInserted();
String deleted=model.getDeleted();
String updated=model.getUpdated();
//转为json
JSONArray insertedJson = JSONArray.fromObject(inserted);
JSONArray deletedJson = JSONArray.fromObject(deleted);
JSONArray updatedJson = JSONArray.fromObject(updated);
if(null != insertedJson)
{
for(int i = 0;i < insertedJson.size(); i++)
{
DepotItem depotItem = new DepotItem();
JSONObject tempInsertedJson = JSONObject.fromObject(insertedJson.get(i));
depotItem.setHeaderId(new DepotHead(headerId));
depotItem.setMaterialId(new Material(tempInsertedJson.getLong("MaterialId")));
depotItem.setOperNumber(tempInsertedJson.getDouble("OperNumber"));
if(tempInsertedJson.get("UnitPrice")!=null){depotItem.setUnitPrice(tempInsertedJson.getDouble("UnitPrice"));}
if(tempInsertedJson.get("Incidentals")!=null){depotItem.setIncidentals(0.0);}
depotItem.setRemark(tempInsertedJson.getString("Remark"));
depotItem.setImg(tempInsertedJson.getString("Img"));
depotItemService.create(depotItem);
}
}
if(null != deletedJson)
{
for(int i = 0;i < deletedJson.size(); i++)
{
JSONObject tempDeletedJson = JSONObject.fromObject(deletedJson.get(i));
depotItemService.delete(tempDeletedJson.getLong("Id"));
}
}
if(null != updatedJson)
{
for(int i = 0;i < updatedJson.size(); i++)
{
JSONObject tempUpdatedJson = JSONObject.fromObject(updatedJson.get(i));
DepotItem depotItem = depotItemService.get(tempUpdatedJson.getLong("Id"));
depotItem.setMaterialId(new Material(tempUpdatedJson.getLong("MaterialId")));
depotItem.setOperNumber(tempUpdatedJson.getDouble("OperNumber"));
if(tempUpdatedJson.get("UnitPrice")!=null){depotItem.setUnitPrice(tempUpdatedJson.getDouble("UnitPrice"));}
if(tempUpdatedJson.get("Incidentals")!=null){depotItem.setIncidentals(0.0);}
depotItem.setRemark(tempUpdatedJson.getString("Remark"));
depotItem.setImg(tempUpdatedJson.getString("Img"));
depotItemService.create(depotItem);
}
}
//========标识位===========
flag = true;
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>保存仓管通明细信息异常", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>保存仓管通明细信息回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "保存仓管通明细", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "保存仓管通明细对应主表编号为 "+ model.getHeaderId() + " " + tipMsg + "", "保存仓管通明细" + tipMsg));
Log.infoFileSync("==================结束调用保存仓管通明细方法saveDetials()===================");
}
/**
* 查找仓管通信息
* @return
*/
public void findBy()
{
try
{
PageUtil<DepotItem> pageUtil = new PageUtil<DepotItem>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition());
depotItemService.find(pageUtil);
List<DepotItem> dataList = pageUtil.getPageList();
//开始拼接json数据
// {"total":28,"rows":[
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
// ]}
JSONObject outer = new JSONObject();
outer.put("total", pageUtil.getTotalCount());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(DepotItem depotItem:dataList)
{
JSONObject item = new JSONObject();
item.put("Id", depotItem.getId());
item.put("MaterialId", depotItem.getMaterialId()==null?"":depotItem.getMaterialId().getId());
item.put("MaterialName", ((depotItem.getMaterialId().getModel().equals(""))?"":""+depotItem.getMaterialId().getModel())+" "+depotItem.getMaterialId().getName()+((depotItem.getMaterialId().getColor() == null)?"(":"("+depotItem.getMaterialId().getColor()) + ")");
item.put("OperNumber", depotItem.getOperNumber());
item.put("UnitPrice", depotItem.getUnitPrice());
item.put("Incidentals", depotItem.getIncidentals());
item.put("Remark", depotItem.getRemark());
item.put("Img", depotItem.getImg());
item.put("op", 1);
dataArray.add(item);
}
}
outer.put("rows", dataArray);
//回写查询结果
toClient(outer.toString());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓管通信息异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓管通信息结果异常", e);
}
}
/**
* 查找进销存
* @return
*/
public void findByAll()
{
try
{
PageUtil<DepotItem> pageUtil = new PageUtil<DepotItem>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getConditionALL());
depotItemService.find(pageUtil);
List<DepotItem> dataList = pageUtil.getPageList();
JSONObject outer = new JSONObject();
outer.put("total", pageUtil.getTotalCount());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(DepotItem depotItem:dataList)
{
JSONObject item = new JSONObject();
Integer prevSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),true) - sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),true);
Integer InSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),false);
Integer OutSum = sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),false);
item.put("Id", depotItem.getId());
item.put("MaterialId", depotItem.getMaterialId()==null?"":depotItem.getMaterialId().getId());
item.put("MaterialName", depotItem.getMaterialId().getName());
item.put("MaterialModel", depotItem.getMaterialId().getModel());
item.put("MaterialColor", depotItem.getMaterialId().getColor());
item.put("prevSum", prevSum);
item.put("InSum", InSum);
item.put("OutSum", OutSum);
item.put("thisSum", prevSum + InSum - OutSum);
item.put("thisAllPrice", depotItem.getUnitPrice() * (prevSum + InSum - OutSum));
item.put("UnitPrice", depotItem.getUnitPrice());
dataArray.add(item);
}
}
outer.put("rows", dataArray);
//回写查询结果
toClient(outer.toString());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e);
}
}
/**
* 统计总计金额
* @return
*/
public void totalCountMoney()
{
try
{
PageUtil<DepotItem> pageUtil = new PageUtil<DepotItem>();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
pageUtil.setAdvSearch(getConditionALL());
depotItemService.find(pageUtil);
List<DepotItem> dataList = pageUtil.getPageList();
JSONObject outer = new JSONObject();
Double thisAllPrice = 0.0;
if(null != dataList)
{
for(DepotItem depotItem:dataList)
{
Integer prevSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),true) - sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),true);
Integer InSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),false);
Integer OutSum = sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),false);
thisAllPrice = thisAllPrice + depotItem.getUnitPrice() * (prevSum + InSum - OutSum);
}
}
outer.put("totalCount", thisAllPrice);
//回写查询结果
toClient(outer.toString());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e);
}
}
/**
* 导出excel表格
* @return
*/
@SuppressWarnings("unchecked")
public String exportExcel()
{
Log.infoFileSync("===================调用导出信息action方法exportExcel开始=======================");
try
{
PageUtil<DepotItem> pageUtil = new PageUtil<DepotItem>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getConditionALL());
depotItemService.find(pageUtil);
List<DepotItem> dataList = pageUtil.getPageList();
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(DepotItem depotItem:dataList)
{
JSONObject item = new JSONObject();
Integer prevSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),true) - sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),true);
Integer InSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),false);
Integer OutSum = sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),false);
item.put("Id", depotItem.getId());
item.put("MaterialId", depotItem.getMaterialId()==null?"":depotItem.getMaterialId().getId());
item.put("MaterialName", depotItem.getMaterialId().getName());
item.put("MaterialModel", depotItem.getMaterialId().getModel());
item.put("MaterialColor", depotItem.getMaterialId().getColor());
item.put("prevSum", prevSum);
item.put("InSum", InSum);
item.put("OutSum", OutSum);
item.put("thisSum", prevSum + InSum - OutSum);
item.put("thisAllPrice", depotItem.getUnitPrice() * (prevSum + InSum - OutSum));
item.put("UnitPrice", depotItem.getUnitPrice());
dataArray.add(item);
}
}
String isCurrentPage = "allPage";
model.setFileName(Tools.changeUnicode("report.xls",model.getBrowserType()));
model.setExcelStream(depotItemService.exmportExcel(isCurrentPage,dataArray));
}
catch (Exception e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>调用导出信息action方法exportExcel异常",e);
model.getShowModel().setMsgTip("export excel exception");
}
Log.infoFileSync("===================调用导出信息action方法exportExcel结束==================");
return EXCEL;
}
@SuppressWarnings("unchecked")
public Integer sumNumber(String type,Long MId,String MonthTime, Boolean isPrev) {
Integer sumNumber = 0;
String allNumber = "";
PageUtil pageUtil = new PageUtil();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
try {
depotItemService.findByType(pageUtil, type, MId, MonthTime, isPrev);
allNumber = pageUtil.getPageList().toString();
allNumber = allNumber.substring(1,allNumber.length()-1);
if(allNumber.equals("null")){
allNumber = "0";
}
allNumber = allNumber.replace(".0", "");
} catch (AmsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
sumNumber = Integer.parseInt(allNumber);
return sumNumber;
}
/**
* 拼接搜索条件
* @return
*/
private Map<String,Object> getCondition()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("HeaderId_n_eq", model.getHeaderId());
condition.put("Id_s_order","asc");
return condition;
}
private Map<String,Object> getConditionALL()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("HeaderId_s_in", model.getHeadIds());
condition.put("MaterialId_s_in", model.getMaterialIds());
condition.put("MaterialId_s_gb","aaa");
return condition;
}
//=============以下spring注入以及Model驱动公共方法与Action处理无关==================
@Override
public DepotItemModel getModel()
{
return model;
}
public void setDepotItemService(DepotItemIService depotItemService)
{
this.depotItemService = depotItemService;
}
}
package com.jsh.action.materials;
import java.io.File;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
import com.jsh.base.BaseAction;
import com.jsh.base.Log;
import com.jsh.constants.asset.AssetConstants;
import com.jsh.exception.JshException;
import com.jsh.model.po.Asset;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.DepotItem;
import com.jsh.model.po.Logdetails;
import com.jsh.model.po.Material;
import com.jsh.model.vo.materials.DepotItemModel;
import com.jsh.service.materials.DepotHeadIService;
import com.jsh.service.materials.DepotItemIService;
import com.jsh.util.common.PageUtil;
import com.jsh.util.common.Tools;
@SuppressWarnings("serial")
public class DepotItemAction extends BaseAction<DepotItemModel>
{
private DepotItemIService depotItemService;
private DepotItemModel model = new DepotItemModel();
/**
* action返回excel结果
*/
public static final String EXCEL = "excel";
/**
* 保存明细
* @return
*/
public void saveDetials()
{
Log.infoFileSync("==================开始调用保存仓管通明细信息方法saveDetials()===================");
Boolean flag = false;
try
{
Long headerId=model.getHeaderId();
String inserted=model.getInserted();
String deleted=model.getDeleted();
String updated=model.getUpdated();
//转为json
JSONArray insertedJson = JSONArray.fromObject(inserted);
JSONArray deletedJson = JSONArray.fromObject(deleted);
JSONArray updatedJson = JSONArray.fromObject(updated);
if(null != insertedJson)
{
for(int i = 0;i < insertedJson.size(); i++)
{
DepotItem depotItem = new DepotItem();
JSONObject tempInsertedJson = JSONObject.fromObject(insertedJson.get(i));
depotItem.setHeaderId(new DepotHead(headerId));
depotItem.setMaterialId(new Material(tempInsertedJson.getLong("MaterialId")));
depotItem.setOperNumber(tempInsertedJson.getDouble("OperNumber"));
if(tempInsertedJson.get("UnitPrice")!=null){depotItem.setUnitPrice(tempInsertedJson.getDouble("UnitPrice"));}
if(tempInsertedJson.get("Incidentals")!=null){depotItem.setIncidentals(0.0);}
depotItem.setRemark(tempInsertedJson.getString("Remark"));
depotItem.setImg(tempInsertedJson.getString("Img"));
depotItemService.create(depotItem);
}
}
if(null != deletedJson)
{
for(int i = 0;i < deletedJson.size(); i++)
{
JSONObject tempDeletedJson = JSONObject.fromObject(deletedJson.get(i));
depotItemService.delete(tempDeletedJson.getLong("Id"));
}
}
if(null != updatedJson)
{
for(int i = 0;i < updatedJson.size(); i++)
{
JSONObject tempUpdatedJson = JSONObject.fromObject(updatedJson.get(i));
DepotItem depotItem = depotItemService.get(tempUpdatedJson.getLong("Id"));
depotItem.setMaterialId(new Material(tempUpdatedJson.getLong("MaterialId")));
depotItem.setOperNumber(tempUpdatedJson.getDouble("OperNumber"));
if(tempUpdatedJson.get("UnitPrice")!=null){depotItem.setUnitPrice(tempUpdatedJson.getDouble("UnitPrice"));}
if(tempUpdatedJson.get("Incidentals")!=null){depotItem.setIncidentals(0.0);}
depotItem.setRemark(tempUpdatedJson.getString("Remark"));
depotItem.setImg(tempUpdatedJson.getString("Img"));
depotItemService.create(depotItem);
}
}
//========标识位===========
flag = true;
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>保存仓管通明细信息异常", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>保存仓管通明细信息回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "保存仓管通明细", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "保存仓管通明细对应主表编号为 "+ model.getHeaderId() + " " + tipMsg + "", "保存仓管通明细" + tipMsg));
Log.infoFileSync("==================结束调用保存仓管通明细方法saveDetials()===================");
}
/**
* 查找仓管通信息
* @return
*/
public void findBy()
{
try
{
PageUtil<DepotItem> pageUtil = new PageUtil<DepotItem>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition());
depotItemService.find(pageUtil);
List<DepotItem> dataList = pageUtil.getPageList();
//开始拼接json数据
// {"total":28,"rows":[
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
// ]}
JSONObject outer = new JSONObject();
outer.put("total", pageUtil.getTotalCount());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(DepotItem depotItem:dataList)
{
JSONObject item = new JSONObject();
item.put("Id", depotItem.getId());
item.put("MaterialId", depotItem.getMaterialId()==null?"":depotItem.getMaterialId().getId());
item.put("MaterialName", ((depotItem.getMaterialId().getModel().equals(""))?"":""+depotItem.getMaterialId().getModel())+" "+depotItem.getMaterialId().getName()+((depotItem.getMaterialId().getColor() == null)?"(":"("+depotItem.getMaterialId().getColor()) + ")");
item.put("OperNumber", depotItem.getOperNumber());
item.put("UnitPrice", depotItem.getUnitPrice());
item.put("Incidentals", depotItem.getIncidentals());
item.put("Remark", depotItem.getRemark());
item.put("Img", depotItem.getImg());
item.put("op", 1);
dataArray.add(item);
}
}
outer.put("rows", dataArray);
//回写查询结果
toClient(outer.toString());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓管通信息异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓管通信息结果异常", e);
}
}
/**
* 查找进销存
* @return
*/
public void findByAll()
{
try
{
PageUtil<DepotItem> pageUtil = new PageUtil<DepotItem>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getConditionALL());
depotItemService.find(pageUtil);
List<DepotItem> dataList = pageUtil.getPageList();
JSONObject outer = new JSONObject();
outer.put("total", pageUtil.getTotalCount());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(DepotItem depotItem:dataList)
{
JSONObject item = new JSONObject();
Integer prevSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),true) - sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),true);
Integer InSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),false);
Integer OutSum = sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),false);
item.put("Id", depotItem.getId());
item.put("MaterialId", depotItem.getMaterialId()==null?"":depotItem.getMaterialId().getId());
item.put("MaterialName", depotItem.getMaterialId().getName());
item.put("MaterialModel", depotItem.getMaterialId().getModel());
item.put("MaterialColor", depotItem.getMaterialId().getColor());
item.put("prevSum", prevSum);
item.put("InSum", InSum);
item.put("OutSum", OutSum);
item.put("thisSum", prevSum + InSum - OutSum);
item.put("thisAllPrice", depotItem.getUnitPrice() * (prevSum + InSum - OutSum));
item.put("UnitPrice", depotItem.getUnitPrice());
dataArray.add(item);
}
}
outer.put("rows", dataArray);
//回写查询结果
toClient(outer.toString());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e);
}
}
/**
* 统计总计金额
* @return
*/
public void totalCountMoney()
{
try
{
PageUtil<DepotItem> pageUtil = new PageUtil<DepotItem>();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
pageUtil.setAdvSearch(getConditionALL());
depotItemService.find(pageUtil);
List<DepotItem> dataList = pageUtil.getPageList();
JSONObject outer = new JSONObject();
Double thisAllPrice = 0.0;
if(null != dataList)
{
for(DepotItem depotItem:dataList)
{
Integer prevSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),true) - sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),true);
Integer InSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),false);
Integer OutSum = sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),false);
thisAllPrice = thisAllPrice + depotItem.getUnitPrice() * (prevSum + InSum - OutSum);
}
}
outer.put("totalCount", thisAllPrice);
//回写查询结果
toClient(outer.toString());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e);
}
}
/**
* 导出excel表格
* @return
*/
@SuppressWarnings("unchecked")
public String exportExcel()
{
Log.infoFileSync("===================调用导出信息action方法exportExcel开始=======================");
try
{
PageUtil<DepotItem> pageUtil = new PageUtil<DepotItem>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getConditionALL());
depotItemService.find(pageUtil);
List<DepotItem> dataList = pageUtil.getPageList();
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(DepotItem depotItem:dataList)
{
JSONObject item = new JSONObject();
Integer prevSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),true) - sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),true);
Integer InSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),false);
Integer OutSum = sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),false);
item.put("Id", depotItem.getId());
item.put("MaterialId", depotItem.getMaterialId()==null?"":depotItem.getMaterialId().getId());
item.put("MaterialName", depotItem.getMaterialId().getName());
item.put("MaterialModel", depotItem.getMaterialId().getModel());
item.put("MaterialColor", depotItem.getMaterialId().getColor());
item.put("prevSum", prevSum);
item.put("InSum", InSum);
item.put("OutSum", OutSum);
item.put("thisSum", prevSum + InSum - OutSum);
item.put("thisAllPrice", depotItem.getUnitPrice() * (prevSum + InSum - OutSum));
item.put("UnitPrice", depotItem.getUnitPrice());
dataArray.add(item);
}
}
String isCurrentPage = "allPage";
model.setFileName(Tools.changeUnicode("report.xls",model.getBrowserType()));
model.setExcelStream(depotItemService.exmportExcel(isCurrentPage,dataArray));
}
catch (Exception e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>调用导出信息action方法exportExcel异常",e);
model.getShowModel().setMsgTip("export excel exception");
}
Log.infoFileSync("===================调用导出信息action方法exportExcel结束==================");
return EXCEL;
}
@SuppressWarnings("unchecked")
public Integer sumNumber(String type,Long MId,String MonthTime, Boolean isPrev) {
Integer sumNumber = 0;
String allNumber = "";
PageUtil pageUtil = new PageUtil();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
try {
depotItemService.findByType(pageUtil, type, MId, MonthTime, isPrev);
allNumber = pageUtil.getPageList().toString();
allNumber = allNumber.substring(1,allNumber.length()-1);
if(allNumber.equals("null")){
allNumber = "0";
}
allNumber = allNumber.replace(".0", "");
} catch (JshException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
sumNumber = Integer.parseInt(allNumber);
return sumNumber;
}
/**
* 拼接搜索条件
* @return
*/
private Map<String,Object> getCondition()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("HeaderId_n_eq", model.getHeaderId());
condition.put("Id_s_order","asc");
return condition;
}
private Map<String,Object> getConditionALL()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("HeaderId_s_in", model.getHeadIds());
condition.put("MaterialId_s_in", model.getMaterialIds());
condition.put("MaterialId_s_gb","aaa");
return condition;
}
//=============以下spring注入以及Model驱动公共方法与Action处理无关==================
@Override
public DepotItemModel getModel()
{
return model;
}
public void setDepotItemService(DepotItemIService depotItemService)
{
this.depotItemService = depotItemService;
}
}

View File

@ -1,116 +1,116 @@
package com.jsh.base;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.jsh.model.po.Basicuser;
import com.jsh.service.basic.LogIService;
/**
* struts2工具类
* @author andy
* struts2 base action 一些常用方法获取
*/
@SuppressWarnings("serial")
public abstract class BaseAction<T> extends ActionSupport implements ModelDriven<T>
{
public LogIService logService;
/**
* 操作日志使用 是否成功表示
*/
public String tipMsg = "成功";
/**
* 操作日志使用 是否成功表示 0 ==成功 1==失败
*/
public short tipType = 0;
public void setLogService(LogIService logService)
{
this.logService = logService;
}
/**
* 获取session
* @return
*/
public static Map<String,Object> getSession()
{
return ActionContext.getContext().getSession();
}
/**
* 获取request
* @return
*/
public static HttpServletRequest getRequest()
{
return ServletActionContext.getRequest();
}
/**
* 获取response
* @return response
*/
public static HttpServletResponse getResponse()
{
return ServletActionContext.getResponse();
}
/**
* 添加错误信息
* @param anErrorMessage
*/
public void addActionError(String anErrorMessage)
{
super.addActionError(anErrorMessage);
}
/**
* 添加消息
* @param aMessage
*/
public void addActionMessage(String aMessage)
{
clearErrorsAndMessages();
super.addActionMessage(aMessage);
}
/**
* 添加字段错误
* @param fieldName
* @param errorMessage
*/
public void addFieldError(String fieldName, String errorMessage)
{
clearErrorsAndMessages();
super.addFieldError(fieldName, errorMessage);
}
/**
* 登录用户信息
* @return 登录用户对象
*/
public Basicuser getUser()
{
return (Basicuser)getSession().get("user");
}
/**
* 回写客户端数据
* @throws IOException
*/
public void toClient(String jsonData) throws IOException
{
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text/html;charset=utf-8");
response.getWriter().print(jsonData);
}
}
package com.jsh.base;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.jsh.model.po.Basicuser;
import com.jsh.service.basic.LogIService;
/**
* struts2工具类
* @author jishenghua
* struts2 base action 一些常用方法获取
*/
@SuppressWarnings("serial")
public abstract class BaseAction<T> extends ActionSupport implements ModelDriven<T>
{
public LogIService logService;
/**
* 操作日志使用 是否成功表示
*/
public String tipMsg = "成功";
/**
* 操作日志使用 是否成功表示 0 ==成功 1==失败
*/
public short tipType = 0;
public void setLogService(LogIService logService)
{
this.logService = logService;
}
/**
* 获取session
* @return
*/
public static Map<String,Object> getSession()
{
return ActionContext.getContext().getSession();
}
/**
* 获取request
* @return
*/
public static HttpServletRequest getRequest()
{
return ServletActionContext.getRequest();
}
/**
* 获取response
* @return response
*/
public static HttpServletResponse getResponse()
{
return ServletActionContext.getResponse();
}
/**
* 添加错误信息
* @param anErrorMessage
*/
public void addActionError(String anErrorMessage)
{
super.addActionError(anErrorMessage);
}
/**
* 添加消息
* @param aMessage
*/
public void addActionMessage(String aMessage)
{
clearErrorsAndMessages();
super.addActionMessage(aMessage);
}
/**
* 添加字段错误
* @param fieldName
* @param errorMessage
*/
public void addFieldError(String fieldName, String errorMessage)
{
clearErrorsAndMessages();
super.addFieldError(fieldName, errorMessage);
}
/**
* 登录用户信息
* @return 登录用户对象
*/
public Basicuser getUser()
{
return (Basicuser)getSession().get("user");
}
/**
* 回写客户端数据
* @throws IOException
*/
public void toClient(String jsonData) throws IOException
{
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text/html;charset=utf-8");
response.getWriter().print(jsonData);
}
}

View File

@ -1,124 +1,124 @@
package com.jsh.base;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.springframework.dao.DataAccessException;
import com.jsh.util.common.PageUtil;
/**
* 常用增删改查操作
* @author andy
* @param <T>
*/
public interface BaseIDAO<T>
{
/**
* 设置操作类对象
* @param paramClass
*/
void setPoJoClass(Class<T> paramClass);
/**
* 增加
* @param t 对象
* @throws DataAccessException
*/
Serializable create(T t)throws DataAccessException;
/**
* 增加
* @param t 对象
* @throws DataAccessException
*/
void save(T t)throws DataAccessException;
/**
* 删除
* @param t 对象
* @throws DataAccessException
*/
void delete(T t)throws DataAccessException;
/**
* 获取
* @param objID ID
* @return 对象
* @throws DataAccessException
*/
T get(Long objID)throws DataAccessException;
/**
* 修改信息
* @param t 要修改的对象
* @throws DataAccessException
*/
void update(T t)throws DataAccessException;
/**
* 批量删除信息
* @param 以逗号分割的ID
* @throws DataAccessException
*/
void batchDelete(String objIDs)throws DataAccessException;
/**
* 查找列表
* @param pageUtil 分页工具类
* @throws DataAccessException
*/
void find(PageUtil<T> pageUtil)throws DataAccessException;
/**
* 根据条件查询列表--没有分页信息
* @param conditon 查询条件
* @return 查询列表数据
*/
List<T> find(Map<String,Object> conditon)throws DataAccessException;
/**
* 根据hql查询 --没有分页信息
* @param hql hibernate查询
* @return 查询列表数据
*/
List<T> find(String hql)throws DataAccessException;
/**
* 根据搜索条件查询--分页
* @param conditon 查询条件
* @param pageSize 每页个数
* @param pageNo 页码
* @return 查询列表数据
* @throws DataAccessException
*/
List<T> find(Map<String,Object> conditon,int pageSize,int pageNo)throws DataAccessException;
/**
* 根据hql查询--分页
* @param hql hibernate查询语句
* @param pageSize 每页个数
* @param pageNo 页码
* @return 查询列表数据
* @throws DataAccessException
*/
List<T> find(String hql,int pageSize,int pageNo)throws DataAccessException;
/**
* 查找符合条件的总数
* @param conditon
* @return
* @throws DataAccessException
*/
Integer countSum(Map<String,Object> conditon)throws DataAccessException;
/**
* 查找符合条件的总数
* @param hql
* @return
* @throws DataAccessException
*/
Integer countSum(String hql)throws DataAccessException;
}
package com.jsh.base;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.springframework.dao.DataAccessException;
import com.jsh.util.common.PageUtil;
/**
* 常用增删改查操作
* @author jishenghua
* @param <T>
*/
public interface BaseIDAO<T>
{
/**
* 设置操作类对象
* @param paramClass
*/
void setPoJoClass(Class<T> paramClass);
/**
* 增加
* @param t 对象
* @throws DataAccessException
*/
Serializable create(T t)throws DataAccessException;
/**
* 增加
* @param t 对象
* @throws DataAccessException
*/
void save(T t)throws DataAccessException;
/**
* 删除
* @param t 对象
* @throws DataAccessException
*/
void delete(T t)throws DataAccessException;
/**
* 获取
* @param objID ID
* @return 对象
* @throws DataAccessException
*/
T get(Long objID)throws DataAccessException;
/**
* 修改信息
* @param t 要修改的对象
* @throws DataAccessException
*/
void update(T t)throws DataAccessException;
/**
* 批量删除信息
* @param 以逗号分割的ID
* @throws DataAccessException
*/
void batchDelete(String objIDs)throws DataAccessException;
/**
* 查找列表
* @param pageUtil 分页工具类
* @throws DataAccessException
*/
void find(PageUtil<T> pageUtil)throws DataAccessException;
/**
* 根据条件查询列表--没有分页信息
* @param conditon 查询条件
* @return 查询列表数据
*/
List<T> find(Map<String,Object> conditon)throws DataAccessException;
/**
* 根据hql查询 --没有分页信息
* @param hql hibernate查询
* @return 查询列表数据
*/
List<T> find(String hql)throws DataAccessException;
/**
* 根据搜索条件查询--分页
* @param conditon 查询条件
* @param pageSize 每页个数
* @param pageNo 页码
* @return 查询列表数据
* @throws DataAccessException
*/
List<T> find(Map<String,Object> conditon,int pageSize,int pageNo)throws DataAccessException;
/**
* 根据hql查询--分页
* @param hql hibernate查询语句
* @param pageSize 每页个数
* @param pageNo 页码
* @return 查询列表数据
* @throws DataAccessException
*/
List<T> find(String hql,int pageSize,int pageNo)throws DataAccessException;
/**
* 查找符合条件的总数
* @param conditon
* @return
* @throws DataAccessException
*/
Integer countSum(Map<String,Object> conditon)throws DataAccessException;
/**
* 查找符合条件的总数
* @param hql
* @return
* @throws DataAccessException
*/
Integer countSum(String hql)throws DataAccessException;
}

View File

@ -1,137 +1,137 @@
package com.jsh.base;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.dao.DataAccessException;
import com.jsh.exception.AmsException;
import com.jsh.model.po.Basicuser;
import com.jsh.util.common.PageUtil;
public abstract class BaseService<T> implements BaseIService<T>
{
/**
* Dao对象
*/
private BaseIDAO<T> baseDao;
protected Class<T> entityClass;
public void setBaseDao(BaseIDAO<T> baseDao)
{
this.baseDao = baseDao;
setPoJoClass(getEntityClass());
}
protected BaseIDAO<T> getBaseDao()
{
return this.baseDao;
}
private void setPoJoClass(Class<T> c)
{
this.baseDao.setPoJoClass(c);
}
protected abstract Class<T> getEntityClass();
@Override
public Serializable create(T t) throws DataAccessException
{
return baseDao.create(t);
}
@Override
public void save(T t) throws DataAccessException
{
baseDao.save(t);
}
@Override
public void delete(T t) throws DataAccessException
{
baseDao.delete(t);
}
@Override
public void delete(Long id) throws DataAccessException
{
baseDao.batchDelete(id.toString());
}
@Override
public T get(Long objID) throws DataAccessException
{
return baseDao.get(objID);
}
@Override
public void update(T t) throws DataAccessException
{
baseDao.update(t);
}
@Override
public void batchDelete(String objIDs) throws DataAccessException
{
baseDao.batchDelete(objIDs);
}
@Override
public void find(PageUtil<T> pageUtil) throws DataAccessException
{
baseDao.find(pageUtil);
}
@Override
public Boolean checkIsNameExist(String filedName, String filedVale,String idFiled,Long objectID) throws DataAccessException
{
PageUtil<T> pageUtil = new PageUtil<T>();
Map<String,Object> condition = new HashMap<String,Object>();
condition.put(filedName + "_s_eq", filedVale);
condition.put(idFiled + "_n_neq", objectID);
pageUtil.setAdvSearch(condition);
baseDao.find(pageUtil);
List<T> dataList = pageUtil.getPageList();
if(null != dataList && dataList.size() > 0)
return true;
return false;
}
@Override
public Boolean checkIsUserBusinessExist(String TypeName,String TypeVale,String KeyIdName,String KeyIdValue,String UBName,String UBValue) throws DataAccessException
{
PageUtil<T> pageUtil = new PageUtil<T>();
Map<String,Object> condition = new HashMap<String,Object>();
condition.put(TypeName + "_s_eq", TypeVale);
condition.put(KeyIdName + "_s_eq", KeyIdValue);
condition.put(UBName + "_s_like", UBValue);
pageUtil.setAdvSearch(condition);
baseDao.find(pageUtil);
List<T> dataList = pageUtil.getPageList();
if(null != dataList && dataList.size() > 0)
return true;
return false;
}
@Override
public Boolean checkIsValueExist(String TypeName, String TypeVale, String KeyIdName, String KeyIdValue) throws DataAccessException
{
PageUtil<T> pageUtil = new PageUtil<T>();
Map<String,Object> condition = new HashMap<String,Object>();
condition.put(TypeName + "_s_eq", TypeVale);
condition.put(KeyIdName + "_s_eq", KeyIdValue);
pageUtil.setAdvSearch(condition);
baseDao.find(pageUtil);
List<T> dataList = pageUtil.getPageList();
if(null != dataList && dataList.size() > 0)
return true;
return false;
}
}
package com.jsh.base;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.dao.DataAccessException;
import com.jsh.exception.JshException;
import com.jsh.model.po.Basicuser;
import com.jsh.util.common.PageUtil;
public abstract class BaseService<T> implements BaseIService<T>
{
/**
* Dao对象
*/
private BaseIDAO<T> baseDao;
protected Class<T> entityClass;
public void setBaseDao(BaseIDAO<T> baseDao)
{
this.baseDao = baseDao;
setPoJoClass(getEntityClass());
}
protected BaseIDAO<T> getBaseDao()
{
return this.baseDao;
}
private void setPoJoClass(Class<T> c)
{
this.baseDao.setPoJoClass(c);
}
protected abstract Class<T> getEntityClass();
@Override
public Serializable create(T t) throws DataAccessException
{
return baseDao.create(t);
}
@Override
public void save(T t) throws DataAccessException
{
baseDao.save(t);
}
@Override
public void delete(T t) throws DataAccessException
{
baseDao.delete(t);
}
@Override
public void delete(Long id) throws DataAccessException
{
baseDao.batchDelete(id.toString());
}
@Override
public T get(Long objID) throws DataAccessException
{
return baseDao.get(objID);
}
@Override
public void update(T t) throws DataAccessException
{
baseDao.update(t);
}
@Override
public void batchDelete(String objIDs) throws DataAccessException
{
baseDao.batchDelete(objIDs);
}
@Override
public void find(PageUtil<T> pageUtil) throws DataAccessException
{
baseDao.find(pageUtil);
}
@Override
public Boolean checkIsNameExist(String filedName, String filedVale,String idFiled,Long objectID) throws DataAccessException
{
PageUtil<T> pageUtil = new PageUtil<T>();
Map<String,Object> condition = new HashMap<String,Object>();
condition.put(filedName + "_s_eq", filedVale);
condition.put(idFiled + "_n_neq", objectID);
pageUtil.setAdvSearch(condition);
baseDao.find(pageUtil);
List<T> dataList = pageUtil.getPageList();
if(null != dataList && dataList.size() > 0)
return true;
return false;
}
@Override
public Boolean checkIsUserBusinessExist(String TypeName,String TypeVale,String KeyIdName,String KeyIdValue,String UBName,String UBValue) throws DataAccessException
{
PageUtil<T> pageUtil = new PageUtil<T>();
Map<String,Object> condition = new HashMap<String,Object>();
condition.put(TypeName + "_s_eq", TypeVale);
condition.put(KeyIdName + "_s_eq", KeyIdValue);
condition.put(UBName + "_s_like", UBValue);
pageUtil.setAdvSearch(condition);
baseDao.find(pageUtil);
List<T> dataList = pageUtil.getPageList();
if(null != dataList && dataList.size() > 0)
return true;
return false;
}
@Override
public Boolean checkIsValueExist(String TypeName, String TypeVale, String KeyIdName, String KeyIdValue) throws DataAccessException
{
PageUtil<T> pageUtil = new PageUtil<T>();
Map<String,Object> condition = new HashMap<String,Object>();
condition.put(TypeName + "_s_eq", TypeVale);
condition.put(KeyIdName + "_s_eq", KeyIdValue);
pageUtil.setAdvSearch(condition);
baseDao.find(pageUtil);
List<T> dataList = pageUtil.getPageList();
if(null != dataList && dataList.size() > 0)
return true;
return false;
}
}

View File

@ -1,174 +1,174 @@
package com.jsh.base;
import org.apache.log4j.Logger;
/**
* 封装log4j日志信息打印日志信息类
* @author andy
* @since 2014-01-22
*/
public class Log
{
/**
* 根据异常信息获取调用类的信息
*/
private static final Exception ex = new Exception();
/**
* 获取Log4j实例
*/
private static final Logger log = Logger.getLogger("ams");
/**
* 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 = "##########";
/**
* 打印deug日期信息
* @param msg 日志信息
*/
public static void debugFileSync(Object msg)
{
log.debug(getLogDetail(msg));
}
/**
* 打印debug异常信息
* @param msg 日志信息
* @param e 异常堆栈
*/
public static void debugFileSync(Object msg, Throwable e)
{
log.debug(getLogDetail(msg), e);
}
/**
* 打印info日志信息
* @param msg 日志信息
*/
public static void infoFileSync(Object msg)
{
log.info(getLogDetail(msg));
}
/**
* 打印 info日志带异常信息
* @param msg 日志信息
* @param e 异常堆栈
*/
public static void infoFileSync(Object msg, Throwable e)
{
log.info(getLogDetail(msg), e);
}
/**
* 打印warn日期信息
* @param msg 日志信息
*/
public static void warnFileSync(Object msg)
{
log.warn(getLogDetail(msg));
}
/**
* 打印warn日志信息带异常
* @param msg日志信息
* @param e 异常堆栈
*/
public static void warnFileSync(Object msg, Throwable e)
{
log.warn(getLogDetail(msg), e);
}
/**
* 打印error日志信息
* @param msg 日志信息
*/
public static void errorFileSync(Object msg)
{
log.error(getLogDetail(msg));
}
/**
* 打印error日志信息带异常
* @param msg 日志信息
* @param e 异常堆栈
*/
public static void errorFileSync(Object msg, Throwable e)
{
log.error(getLogDetail(msg), e);
}
/**
* 打印fatal日志信息
* @param msg 日志信息
*/
public static void fatalFileSync(Object msg)
{
log.fatal(getLogDetail(msg));
}
/**
* 打印fatal日志信息带异常
* @param msg 日志信息
* @param e 异常堆栈
*/
public static void fatalFileSync(Object msg, Throwable e)
{
log.fatal(getLogDetail(msg), e);
}
/**
* 拼装日志详细信息
* @param message 要打印的日志信息
* @return 封装后的日志详细信息
*/
private static synchronized String getLogDetail(Object message)
{
String msg = "";
if (null != message)
msg = message.toString();
StringBuffer bf = new StringBuffer();
try
{
ex.fillInStackTrace();
throw ex;
}
catch (Exception ex)
{
StackTraceElement[] trace = ex.getStackTrace();
//获取异常堆栈中的调用类信息
final int pos = 2;
bf.append(msg);
bf.append(" [class:");
bf.append(trace[pos].getClassName());
bf.append(" method:");
bf.append(trace[pos].getMethodName());
bf.append(" line:");
bf.append(trace[pos].getLineNumber());
bf.append("]");
}
return bf.toString();
}
}
package com.jsh.base;
import org.apache.log4j.Logger;
/**
* 封装log4j日志信息打印日志信息类
* @author jishenghua
* @since 2014-01-22
*/
public class Log
{
/**
* 根据异常信息获取调用类的信息
*/
private static final Exception ex = new Exception();
/**
* 获取Log4j实例
*/
private static final Logger log = Logger.getLogger("ams");
/**
* 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 = "##########";
/**
* 打印deug日期信息
* @param msg 日志信息
*/
public static void debugFileSync(Object msg)
{
log.debug(getLogDetail(msg));
}
/**
* 打印debug异常信息
* @param msg 日志信息
* @param e 异常堆栈
*/
public static void debugFileSync(Object msg, Throwable e)
{
log.debug(getLogDetail(msg), e);
}
/**
* 打印info日志信息
* @param msg 日志信息
*/
public static void infoFileSync(Object msg)
{
log.info(getLogDetail(msg));
}
/**
* 打印 info日志带异常信息
* @param msg 日志信息
* @param e 异常堆栈
*/
public static void infoFileSync(Object msg, Throwable e)
{
log.info(getLogDetail(msg), e);
}
/**
* 打印warn日期信息
* @param msg 日志信息
*/
public static void warnFileSync(Object msg)
{
log.warn(getLogDetail(msg));
}
/**
* 打印warn日志信息带异常
* @param msg日志信息
* @param e 异常堆栈
*/
public static void warnFileSync(Object msg, Throwable e)
{
log.warn(getLogDetail(msg), e);
}
/**
* 打印error日志信息
* @param msg 日志信息
*/
public static void errorFileSync(Object msg)
{
log.error(getLogDetail(msg));
}
/**
* 打印error日志信息带异常
* @param msg 日志信息
* @param e 异常堆栈
*/
public static void errorFileSync(Object msg, Throwable e)
{
log.error(getLogDetail(msg), e);
}
/**
* 打印fatal日志信息
* @param msg 日志信息
*/
public static void fatalFileSync(Object msg)
{
log.fatal(getLogDetail(msg));
}
/**
* 打印fatal日志信息带异常
* @param msg 日志信息
* @param e 异常堆栈
*/
public static void fatalFileSync(Object msg, Throwable e)
{
log.fatal(getLogDetail(msg), e);
}
/**
* 拼装日志详细信息
* @param message 要打印的日志信息
* @return 封装后的日志详细信息
*/
private static synchronized String getLogDetail(Object message)
{
String msg = "";
if (null != message)
msg = message.toString();
StringBuffer bf = new StringBuffer();
try
{
ex.fillInStackTrace();
throw ex;
}
catch (Exception ex)
{
StackTraceElement[] trace = ex.getStackTrace();
//获取异常堆栈中的调用类信息
final int pos = 2;
bf.append(msg);
bf.append(" [class:");
bf.append(trace[pos].getClassName());
bf.append(" method:");
bf.append(trace[pos].getMethodName());
bf.append(" line:");
bf.append(trace[pos].getLineNumber());
bf.append("]");
}
return bf.toString();
}
}

View File

@ -1,119 +1,119 @@
package com.jsh.constants.asset;
/**
* 定义资产管理常量
* @author andy
*/
public interface AssetConstants
{
/**
* 公共常量
* @author andy
*/
public class Common
{
}
/**
* 资产常量--导入导出excel表格业务相关
* @author andy
*/
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.constants.asset;
/**
* 定义资产管理常量
* @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";
}
}

View File

@ -1,36 +1,36 @@
package com.jsh.constants.common;
public interface AmsConstants
{
/**
* 定义资产管理公共常量
* @author andy
*/
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.constants.common;
public interface AmsConstants
{
/**
* 定义资产管理公共常量
* @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 = "##########";
}
}

View File

@ -1,65 +1,65 @@
package com.jsh.constants.common;
public interface LogModuleConstants
{
/**
* 系统管理模块名称定义
* @author andy
*/
public class ManageModuleNameCode
{
/**
* 管理模块资产名称
*/
public static final String MODULE_MANAGE_ASSETNAME = "资产名称";
/**
* 管理模块供应商
*/
public static final String MODULE_MANAGE_SUPPLIER = "供应商";
/**
* 管理模块资产类型
*/
public static final String MODULE_MANAGE_CATEGORY = "资产类型";
/**
* 管理模块用户管理
*/
public static final String MODULE_MANAGE_USER = "用户管理";
}
/**
* 资产管理模块名称定义
* @author andy
*/
public class AssetModuleNameCode
{
/**
* 资产管理模块资产管理
*/
public static final String MODULE_ASSET_MANAGE = "资产管理";
/**
* 资产管理模块资产报表
*/
public static final String MODULE_ASSET_REPORT = "资产报表";
/**
* 资产管理模块资产概况
*/
public static final String MODULE_ASSET_GENERAL = "资产概况";
}
/**
* 日志管理模块名称定义
* @author andy
*/
public class LogModuleNameCode
{
/**
* 日志管理模块日志管理
*/
public static final String MODULE_LOG_MANAGE = "日志管理";
}
}
package com.jsh.constants.common;
public interface LogModuleConstants
{
/**
* 系统管理模块名称定义
* @author jishenghua
*/
public class ManageModuleNameCode
{
/**
* 管理模块资产名称
*/
public static final String MODULE_MANAGE_ASSETNAME = "资产名称";
/**
* 管理模块供应商
*/
public static final String MODULE_MANAGE_SUPPLIER = "供应商";
/**
* 管理模块资产类型
*/
public static final String MODULE_MANAGE_CATEGORY = "资产类型";
/**
* 管理模块用户管理
*/
public static final String MODULE_MANAGE_USER = "用户管理";
}
/**
* 资产管理模块名称定义
* @author jishenghua
*/
public class AssetModuleNameCode
{
/**
* 资产管理模块资产管理
*/
public static final String MODULE_ASSET_MANAGE = "资产管理";
/**
* 资产管理模块资产报表
*/
public static final String MODULE_ASSET_REPORT = "资产报表";
/**
* 资产管理模块资产概况
*/
public static final String MODULE_ASSET_GENERAL = "资产概况";
}
/**
* 日志管理模块名称定义
* @author jishenghua
*/
public class LogModuleNameCode
{
/**
* 日志管理模块日志管理
*/
public static final String MODULE_LOG_MANAGE = "日志管理";
}
}

View File

@ -1,21 +1,21 @@
package com.jsh.dao.asset;
import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.jsh.exception.AmsException;
import com.jsh.model.po.Asset;
import com.jsh.util.common.PageUtil;
import com.jsh.util.common.SearchConditionUtil;
public class ReportDAO extends HibernateDaoSupport implements ReportIDAO
{
@SuppressWarnings("unchecked")
@Override
public void find(PageUtil<Asset> pageUtil,String reportType,String reportName) throws AmsException
{
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select count(" + reportType +") as dataSum, " + reportName + " from Asset asset where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
pageUtil.setTotalCount(query.list().size());
pageUtil.setPageList(query.list());
}
}
package com.jsh.dao.asset;
import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.jsh.exception.JshException;
import com.jsh.model.po.Asset;
import com.jsh.util.common.PageUtil;
import com.jsh.util.common.SearchConditionUtil;
public class ReportDAO extends HibernateDaoSupport implements ReportIDAO
{
@SuppressWarnings("unchecked")
@Override
public void find(PageUtil<Asset> pageUtil,String reportType,String reportName) throws JshException
{
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select count(" + reportType +") as dataSum, " + reportName + " from Asset asset where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
pageUtil.setTotalCount(query.list().size());
pageUtil.setPageList(query.list());
}
}

View File

@ -1,16 +1,16 @@
package com.jsh.dao.asset;
import com.jsh.exception.AmsException;
import com.jsh.model.po.Asset;
import com.jsh.util.common.PageUtil;
public interface ReportIDAO
{
/**
* 查找资产列表
* @param pageUtil 分页工具类
* @param reportType 报表统计字段
* @throws AmsException
*/
void find(PageUtil<Asset> pageUtil,String reportType,String reportName) throws AmsException;
}
package com.jsh.dao.asset;
import com.jsh.exception.JshException;
import com.jsh.model.po.Asset;
import com.jsh.util.common.PageUtil;
public interface ReportIDAO
{
/**
* 查找资产列表
* @param pageUtil 分页工具类
* @param reportType 报表统计字段
* @throws JshException
*/
void find(PageUtil<Asset> pageUtil,String reportType,String reportName) throws JshException;
}

View File

@ -1,32 +1,32 @@
package com.jsh.dao.basic;
import org.hibernate.Query;
import com.jsh.base.BaseDAO;
import com.jsh.exception.AmsException;
import com.jsh.model.po.Asset;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.common.PageUtil;
import com.jsh.util.common.SearchConditionUtil;
public class UserBusinessDAO extends BaseDAO<UserBusiness> implements UserBusinessIDAO
{
/**
* 设置dao映射基类
* @return
*/
@Override
public Class<UserBusiness> getEntityClass()
{
return UserBusiness.class;
}
@SuppressWarnings("unchecked")
@Override
public void find(PageUtil<UserBusiness> pageUtil,String ceshi) throws AmsException
{
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select count(id),sum(id) from UserBusiness userBusiness where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
pageUtil.setTotalCount(query.list().size());
pageUtil.setPageList(query.list());
}
}
package com.jsh.dao.basic;
import org.hibernate.Query;
import com.jsh.base.BaseDAO;
import com.jsh.exception.JshException;
import com.jsh.model.po.Asset;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.common.PageUtil;
import com.jsh.util.common.SearchConditionUtil;
public class UserBusinessDAO extends BaseDAO<UserBusiness> implements UserBusinessIDAO
{
/**
* 设置dao映射基类
* @return
*/
@Override
public Class<UserBusiness> getEntityClass()
{
return UserBusiness.class;
}
@SuppressWarnings("unchecked")
@Override
public void find(PageUtil<UserBusiness> pageUtil,String ceshi) throws JshException
{
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select count(id),sum(id) from UserBusiness userBusiness where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
pageUtil.setTotalCount(query.list().size());
pageUtil.setPageList(query.list());
}
}

View File

@ -1,14 +1,14 @@
package com.jsh.dao.basic;
import com.jsh.base.BaseIDAO;
import com.jsh.exception.AmsException;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.common.PageUtil;
public interface UserBusinessIDAO extends BaseIDAO<UserBusiness>
{
/*
* 测试hql语句
*/
void find(PageUtil<UserBusiness> pageUtil,String ceshi) throws AmsException;
}
package com.jsh.dao.basic;
import com.jsh.base.BaseIDAO;
import com.jsh.exception.JshException;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.common.PageUtil;
public interface UserBusinessIDAO extends BaseIDAO<UserBusiness>
{
/*
* 测试hql语句
*/
void find(PageUtil<UserBusiness> pageUtil,String ceshi) throws JshException;
}

View File

@ -1,32 +1,32 @@
package com.jsh.dao.materials;
import org.hibernate.Query;
import com.jsh.base.BaseDAO;
import com.jsh.exception.AmsException;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.common.PageUtil;
import com.jsh.util.common.SearchConditionUtil;
public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO
{
/**
* 设置dao映射基类
* @return
*/
@Override
public Class<DepotHead> getEntityClass()
{
return DepotHead.class;
}
@SuppressWarnings("unchecked")
@Override
public void find(PageUtil<DepotHead> pageUtil,String maxid) throws AmsException
{
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select max(Id) as Id from DepotHead depotHead where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
pageUtil.setTotalCount(query.list().size());
pageUtil.setPageList(query.list());
}
}
package com.jsh.dao.materials;
import org.hibernate.Query;
import com.jsh.base.BaseDAO;
import com.jsh.exception.JshException;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.common.PageUtil;
import com.jsh.util.common.SearchConditionUtil;
public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO
{
/**
* 设置dao映射基类
* @return
*/
@Override
public Class<DepotHead> getEntityClass()
{
return DepotHead.class;
}
@SuppressWarnings("unchecked")
@Override
public void find(PageUtil<DepotHead> pageUtil,String maxid) throws JshException
{
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select max(Id) as Id from DepotHead depotHead where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
pageUtil.setTotalCount(query.list().size());
pageUtil.setPageList(query.list());
}
}

View File

@ -1,15 +1,15 @@
package com.jsh.dao.materials;
import com.jsh.base.BaseIDAO;
import com.jsh.exception.AmsException;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.common.PageUtil;
public interface DepotHeadIDAO extends BaseIDAO<DepotHead>
{
/*
* 获取MaxId
*/
void find(PageUtil<DepotHead> pageUtil,String maxid) throws AmsException;
}
package com.jsh.dao.materials;
import com.jsh.base.BaseIDAO;
import com.jsh.exception.JshException;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.common.PageUtil;
public interface DepotHeadIDAO extends BaseIDAO<DepotHead>
{
/*
* 获取MaxId
*/
void find(PageUtil<DepotHead> pageUtil,String maxid) throws JshException;
}

View File

@ -1,59 +1,59 @@
package com.jsh.dao.materials;
import org.hibernate.Query;
import com.jsh.base.BaseDAO;
import com.jsh.exception.AmsException;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.DepotItem;
import com.jsh.util.common.PageUtil;
import com.jsh.util.common.SearchConditionUtil;
public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
{
/**
* 设置dao映射基类
* @return
*/
@Override
public Class<DepotItem> getEntityClass()
{
return DepotItem.class;
}
@SuppressWarnings("unchecked")
@Override
public void findByType(PageUtil<DepotItem> pageUtil,String type,Long MId,String MonthTime,Boolean isPrev) throws AmsException
{
//多表联查,多表连查此处用到了createSQLQuery可以随便写sql语句很方便
Query query;
if(isPrev) {
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime <'"+ MonthTime +"-01 00:00:00' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
}
else {
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 00:00:00' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
}
pageUtil.setTotalCount(query.list().size());
pageUtil.setPageList(query.list());
}
@SuppressWarnings("unchecked")
@Override
public void findOrderByMaterial(PageUtil<DepotItem> pageUtil) throws AmsException
{
//多表联查,多表连查此处用到了createSQLQuery可以随便写sql语句很方便
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select * from jsh_depotitem where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
pageUtil.setTotalCount(query.list().size());
// 分页查询
int pageNo = pageUtil.getCurPage();
int pageSize = pageUtil.getPageSize();
if (0 != pageNo && 0 != pageSize)
{
query.setFirstResult((pageNo - 1) * pageSize);
query.setMaxResults(pageSize);
}
pageUtil.setPageList(query.list());
}
}
package com.jsh.dao.materials;
import org.hibernate.Query;
import com.jsh.base.BaseDAO;
import com.jsh.exception.JshException;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.DepotItem;
import com.jsh.util.common.PageUtil;
import com.jsh.util.common.SearchConditionUtil;
public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
{
/**
* 设置dao映射基类
* @return
*/
@Override
public Class<DepotItem> getEntityClass()
{
return DepotItem.class;
}
@SuppressWarnings("unchecked")
@Override
public void findByType(PageUtil<DepotItem> pageUtil,String type,Long MId,String MonthTime,Boolean isPrev) throws JshException
{
//多表联查,多表连查此处用到了createSQLQuery可以随便写sql语句很方便
Query query;
if(isPrev) {
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime <'"+ MonthTime +"-01 00:00:00' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
}
else {
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 00:00:00' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
}
pageUtil.setTotalCount(query.list().size());
pageUtil.setPageList(query.list());
}
@SuppressWarnings("unchecked")
@Override
public void findOrderByMaterial(PageUtil<DepotItem> pageUtil) throws JshException
{
//多表联查,多表连查此处用到了createSQLQuery可以随便写sql语句很方便
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select * from jsh_depotitem where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
pageUtil.setTotalCount(query.list().size());
// 分页查询
int pageNo = pageUtil.getCurPage();
int pageSize = pageUtil.getPageSize();
if (0 != pageNo && 0 != pageSize)
{
query.setFirstResult((pageNo - 1) * pageSize);
query.setMaxResults(pageSize);
}
pageUtil.setPageList(query.list());
}
}

View File

@ -1,14 +1,14 @@
package com.jsh.dao.materials;
import com.jsh.base.BaseIDAO;
import com.jsh.exception.AmsException;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.DepotItem;
import com.jsh.util.common.PageUtil;
public interface DepotItemIDAO extends BaseIDAO<DepotItem>
{
void findByType(PageUtil<DepotItem> pageUtil,String type,Long MId, String MonthTime,Boolean isPrev) throws AmsException;
void findOrderByMaterial(PageUtil<DepotItem> pageUtil) throws AmsException;
}
package com.jsh.dao.materials;
import com.jsh.base.BaseIDAO;
import com.jsh.exception.JshException;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.DepotItem;
import com.jsh.util.common.PageUtil;
public interface DepotItemIDAO extends BaseIDAO<DepotItem>
{
void findByType(PageUtil<DepotItem> pageUtil,String type,Long MId, String MonthTime,Boolean isPrev) throws JshException;
void findOrderByMaterial(PageUtil<DepotItem> pageUtil) throws JshException;
}

View File

@ -1,73 +1,73 @@
package com.jsh.exception;
/**
* @title: 平台异常基类
* @description: 用于包装一些异常信息打印日志等服务
* @author andy
* @since: 2014-01-24
*/
@SuppressWarnings("serial")
public class AmsException extends Exception
{
public long errorCode = -1;
public String message ;
public AmsException()
{
super();
}
public AmsException(String message)
{
super(message);
this.message = message;
}
public AmsException(String message, Throwable cause)
{
super(message, cause);
this.message = message;
}
public AmsException(Throwable cause)
{
super(cause);
}
public AmsException(long errorCode)
{
super();
this.errorCode = errorCode;
}
public AmsException(String message, long errorCode)
{
super(message);
this.errorCode = errorCode;
this.message = message;
}
public AmsException(String message, long errorCode, Throwable cause)
{
super(message, cause);
this.errorCode = errorCode;
this.message = message;
}
public AmsException(long errorCode, Throwable cause)
{
super(cause);
this.errorCode = errorCode;
}
public long getErrorCode()
{
return errorCode;
}
public String getMessage()
{
return message;
}
}
package com.jsh.exception;
/**
* @title: 平台异常基类
* @description: 用于包装一些异常信息打印日志等服务
* @author jishenghua
* @since: 2014-01-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;
}
}

View File

@ -1,83 +1,83 @@
package com.jsh.filter.user;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* 用户登录session处理类
* 过滤session是否超时
* @author andy
* @version [版本号, 2012-3-6]
* @see [相关类/方法]
* @since
*/
public class UserFilter implements Filter
{
/**
* 初始化过滤器 暂不处理
* 重载方法
* @param arg0
* @throws ServletException
*/
public void init(FilterConfig arg0)
throws ServletException
{
}
/**
* 判断用户session是否存在 不存在则跳转到登录页面
* 重载方法
* @param srequest
* @param sresponse
* @param chain
* @throws IOException
* @throws ServletException
*/
public void doFilter(ServletRequest srequest, ServletResponse sresponse, FilterChain chain)
throws IOException, ServletException
{
HttpServletRequest request = (HttpServletRequest) srequest;
HttpServletResponse response = (HttpServletResponse) sresponse;
HttpSession session = request.getSession();
// //定义登录页面不被过滤===后续考虑
// List<String> notFilterFile = new ArrayList<String>();
// notFilterFile.add("/login.jsp");
// notFilterFile.add("/logout.jsp");
// notFilterFile.add("/css/*");
// notFilterFile.add("/css/zTreeStyle/*");
// notFilterFile.add("/css/zTreeStyle/img/*");
// notFilterFile.add("/css/zTreeStyle/img/diy/*");
//获取工程路径
String path = request.getContextPath();
String requestURl = request.getRequestURI();
//提示用户没有权限操作
// response.setCharacterEncoding("utf-8");
// PrintWriter pw=response.getWriter();
// pw.write("<script language='javascript'>alert('您没有权限进行此项操作!')</script>");
//session中有值则不进行处理
if(requestURl.contains("/pages") &&null != session.getAttribute("user"))
chain.doFilter(request, response);
else
response.sendRedirect(path + "/logout.jsp");
}
/**
* 销毁过滤器
*/
public void destroy()
{
}
}
package com.jsh.filter.user;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* 用户登录session处理类
* 过滤session是否超时
* @author jishenghua
* @version [版本号, 2012-3-6]
* @see [相关类/方法]
* @since
*/
public class UserFilter implements Filter
{
/**
* 初始化过滤器 暂不处理
* 重载方法
* @param arg0
* @throws ServletException
*/
public void init(FilterConfig arg0)
throws ServletException
{
}
/**
* 判断用户session是否存在 不存在则跳转到登录页面
* 重载方法
* @param srequest
* @param sresponse
* @param chain
* @throws IOException
* @throws ServletException
*/
public void doFilter(ServletRequest srequest, ServletResponse sresponse, FilterChain chain)
throws IOException, ServletException
{
HttpServletRequest request = (HttpServletRequest) srequest;
HttpServletResponse response = (HttpServletResponse) sresponse;
HttpSession session = request.getSession();
// //定义登录页面不被过滤===后续考虑
// List<String> notFilterFile = new ArrayList<String>();
// notFilterFile.add("/login.jsp");
// notFilterFile.add("/logout.jsp");
// notFilterFile.add("/css/*");
// notFilterFile.add("/css/zTreeStyle/*");
// notFilterFile.add("/css/zTreeStyle/img/*");
// notFilterFile.add("/css/zTreeStyle/img/diy/*");
//获取工程路径
String path = request.getContextPath();
String requestURl = request.getRequestURI();
//提示用户没有权限操作
// response.setCharacterEncoding("utf-8");
// PrintWriter pw=response.getWriter();
// pw.write("<script language='javascript'>alert('您没有权限进行此项操作!')</script>");
//session中有值则不进行处理
if(requestURl.contains("/pages") &&null != session.getAttribute("user"))
chain.doFilter(request, response);
else
response.sendRedirect(path + "/logout.jsp");
}
/**
* 销毁过滤器
*/
public void destroy()
{
}
}

View File

@ -18,7 +18,7 @@
</column>
</property>
<property name="password" type="java.lang.String">
<column name="password" length="30" not-null="true">
<column name="password" length="50" not-null="true">
<comment>登陆密码</comment>
</column>
</property>

View File

@ -1,257 +1,256 @@
package com.jsh.model.vo.materials;
import java.io.Serializable;
import com.sun.jmx.snmp.Timestamp;
@SuppressWarnings("serial")
public class DepotHeadModel implements Serializable
{
private DepotHeadShowModel showModel = new DepotHeadShowModel();
/**======开始接受页面参数=================**/
private String Type = "";
private String SubType = "";
private Long ProjectId;
private String Number = "";
private String OperPersonName = "";
private String OperTime;
private Long OrganId;
private Long HandsPersonId;
private Long WareHousePersonId;
private String SettlementWay = "";
private Long BuildingId;
private Long AllocationProjectId;
private String Remark = "";
private String State = "";
private String ReAuditPersonName = "";
private String Reason = "";
private String BeginTime; //查询开始时间
private String EndTime; //查询结束时间
private String MonthTime; //查询月份
/**
* 分类ID
*/
private Long depotHeadID = 0l;
/**
* 分类IDs 批量操作使用
*/
private String depotHeadIDs = "";
/**
* 每页显示的个数
*/
private int pageSize = 10;
/**
* 当前页码
*/
private int pageNo = 1;
/**
* 用户IP用户记录操作日志
*/
private String clientIp = "";
public DepotHeadShowModel getShowModel() {
return showModel;
}
public void setShowModel(DepotHeadShowModel showModel) {
this.showModel = showModel;
}
public String getType() {
return Type;
}
public void setType(String type) {
Type = type;
}
public String getSubType() {
return SubType;
}
public void setSubType(String subType) {
SubType = subType;
}
public Long getProjectId() {
return ProjectId;
}
public void setProjectId(Long projectId) {
ProjectId = projectId;
}
public String getNumber() {
return Number;
}
public void setNumber(String number) {
Number = number;
}
public String getOperPersonName() {
return OperPersonName;
}
public void setOperPersonName(String operPersonName) {
OperPersonName = operPersonName;
}
public Long getOrganId() {
return OrganId;
}
public void setOrganId(Long organId) {
OrganId = organId;
}
public Long getHandsPersonId() {
return HandsPersonId;
}
public void setHandsPersonId(Long handsPersonId) {
HandsPersonId = handsPersonId;
}
public Long getWareHousePersonId() {
return WareHousePersonId;
}
public void setWareHousePersonId(Long wareHousePersonId) {
WareHousePersonId = wareHousePersonId;
}
public String getSettlementWay() {
return SettlementWay;
}
public void setSettlementWay(String settlementWay) {
SettlementWay = settlementWay;
}
public Long getBuildingId() {
return BuildingId;
}
public void setBuildingId(Long buildingId) {
BuildingId = buildingId;
}
public Long getAllocationProjectId() {
return AllocationProjectId;
}
public void setAllocationProjectId(Long allocationProjectId) {
AllocationProjectId = allocationProjectId;
}
public String getRemark() {
return Remark;
}
public void setRemark(String remark) {
Remark = remark;
}
public String getState() {
return State;
}
public void setState(String state) {
State = state;
}
public String getReAuditPersonName() {
return ReAuditPersonName;
}
public void setReAuditPersonName(String reAuditPersonName) {
ReAuditPersonName = reAuditPersonName;
}
public String getReason() {
return Reason;
}
public void setReason(String reason) {
Reason = reason;
}
public Long getDepotHeadID() {
return depotHeadID;
}
public void setDepotHeadID(Long depotHeadID) {
this.depotHeadID = depotHeadID;
}
public String getDepotHeadIDs() {
return depotHeadIDs;
}
public void setDepotHeadIDs(String depotHeadIDs) {
this.depotHeadIDs = depotHeadIDs;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public String getClientIp() {
return clientIp;
}
public void setClientIp(String clientIp) {
this.clientIp = clientIp;
}
public String getBeginTime() {
return BeginTime;
}
public void setBeginTime(String beginTime) {
BeginTime = beginTime;
}
public String getEndTime() {
return EndTime;
}
public void setEndTime(String endTime) {
EndTime = endTime;
}
public String getOperTime() {
return OperTime;
}
public void setOperTime(String operTime) {
OperTime = operTime;
}
public String getMonthTime() {
return MonthTime;
}
public void setMonthTime(String monthTime) {
MonthTime = monthTime;
}
}
package com.jsh.model.vo.materials;
import java.io.Serializable;
@SuppressWarnings("serial")
public class DepotHeadModel implements Serializable
{
private DepotHeadShowModel showModel = new DepotHeadShowModel();
/**======开始接受页面参数=================**/
private String Type = "";
private String SubType = "";
private Long ProjectId;
private String Number = "";
private String OperPersonName = "";
private String OperTime;
private Long OrganId;
private Long HandsPersonId;
private Long WareHousePersonId;
private String SettlementWay = "";
private Long BuildingId;
private Long AllocationProjectId;
private String Remark = "";
private String State = "";
private String ReAuditPersonName = "";
private String Reason = "";
private String BeginTime; //查询开始时间
private String EndTime; //查询结束时间
private String MonthTime; //查询月份
/**
* 分类ID
*/
private Long depotHeadID = 0l;
/**
* 分类IDs 批量操作使用
*/
private String depotHeadIDs = "";
/**
* 每页显示的个数
*/
private int pageSize = 10;
/**
* 当前页码
*/
private int pageNo = 1;
/**
* 用户IP用户记录操作日志
*/
private String clientIp = "";
public DepotHeadShowModel getShowModel() {
return showModel;
}
public void setShowModel(DepotHeadShowModel showModel) {
this.showModel = showModel;
}
public String getType() {
return Type;
}
public void setType(String type) {
Type = type;
}
public String getSubType() {
return SubType;
}
public void setSubType(String subType) {
SubType = subType;
}
public Long getProjectId() {
return ProjectId;
}
public void setProjectId(Long projectId) {
ProjectId = projectId;
}
public String getNumber() {
return Number;
}
public void setNumber(String number) {
Number = number;
}
public String getOperPersonName() {
return OperPersonName;
}
public void setOperPersonName(String operPersonName) {
OperPersonName = operPersonName;
}
public Long getOrganId() {
return OrganId;
}
public void setOrganId(Long organId) {
OrganId = organId;
}
public Long getHandsPersonId() {
return HandsPersonId;
}
public void setHandsPersonId(Long handsPersonId) {
HandsPersonId = handsPersonId;
}
public Long getWareHousePersonId() {
return WareHousePersonId;
}
public void setWareHousePersonId(Long wareHousePersonId) {
WareHousePersonId = wareHousePersonId;
}
public String getSettlementWay() {
return SettlementWay;
}
public void setSettlementWay(String settlementWay) {
SettlementWay = settlementWay;
}
public Long getBuildingId() {
return BuildingId;
}
public void setBuildingId(Long buildingId) {
BuildingId = buildingId;
}
public Long getAllocationProjectId() {
return AllocationProjectId;
}
public void setAllocationProjectId(Long allocationProjectId) {
AllocationProjectId = allocationProjectId;
}
public String getRemark() {
return Remark;
}
public void setRemark(String remark) {
Remark = remark;
}
public String getState() {
return State;
}
public void setState(String state) {
State = state;
}
public String getReAuditPersonName() {
return ReAuditPersonName;
}
public void setReAuditPersonName(String reAuditPersonName) {
ReAuditPersonName = reAuditPersonName;
}
public String getReason() {
return Reason;
}
public void setReason(String reason) {
Reason = reason;
}
public Long getDepotHeadID() {
return depotHeadID;
}
public void setDepotHeadID(Long depotHeadID) {
this.depotHeadID = depotHeadID;
}
public String getDepotHeadIDs() {
return depotHeadIDs;
}
public void setDepotHeadIDs(String depotHeadIDs) {
this.depotHeadIDs = depotHeadIDs;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public String getClientIp() {
return clientIp;
}
public void setClientIp(String clientIp) {
this.clientIp = clientIp;
}
public String getBeginTime() {
return BeginTime;
}
public void setBeginTime(String beginTime) {
BeginTime = beginTime;
}
public String getEndTime() {
return EndTime;
}
public void setEndTime(String endTime) {
EndTime = endTime;
}
public String getOperTime() {
return OperTime;
}
public void setOperTime(String operTime) {
OperTime = operTime;
}
public String getMonthTime() {
return MonthTime;
}
public void setMonthTime(String monthTime) {
MonthTime = monthTime;
}
}

View File

@ -1,30 +1,30 @@
package com.jsh.service.asset;
import java.io.File;
import java.io.InputStream;
import com.jsh.base.BaseIService;
import com.jsh.exception.AmsException;
import com.jsh.model.po.Asset;
import com.jsh.util.common.PageUtil;
public interface AssetIService extends BaseIService<Asset>
{
/**
* 导出信息
* @return
*/
InputStream exmportExcel(String isAllPage,PageUtil<Asset> pageUtil)throws AmsException;
/**
* 导入资产excel文件--表格格式 媒资列表 || 资产名称-资产类型-单价-用户-购买时间-状态-位置-资产编号-序列号-有效日期-保修日期-供应商-标签-描述
* 业务规则导入时检查资产名称是否存在如存在就不考虑表格中资产类型如资产名不存在就新建资产名类型用表格中的但类型必须是系统中存在的不存在的不能导入
* 资产名称用户可以添加其他的应该不能填
*
* @param assetFile excel表格文件
* @param isCheck 是否检查 0--手工确定 1--直接导入数据库中
* @return 错误的表格数据
* @throws AmsException
*/
InputStream importExcel(File assetFile,int isCheck)throws AmsException;
}
package com.jsh.service.asset;
import java.io.File;
import java.io.InputStream;
import com.jsh.base.BaseIService;
import com.jsh.exception.JshException;
import com.jsh.model.po.Asset;
import com.jsh.util.common.PageUtil;
public interface AssetIService extends BaseIService<Asset>
{
/**
* 导出信息
* @return
*/
InputStream exmportExcel(String isAllPage,PageUtil<Asset> pageUtil)throws JshException;
/**
* 导入资产excel文件--表格格式 媒资列表 || 资产名称-资产类型-单价-用户-购买时间-状态-位置-资产编号-序列号-有效日期-保修日期-供应商-标签-描述
* 业务规则导入时检查资产名称是否存在如存在就不考虑表格中资产类型如资产名不存在就新建资产名类型用表格中的但类型必须是系统中存在的不存在的不能导入
* 资产名称用户可以添加其他的应该不能填
*
* @param assetFile excel表格文件
* @param isCheck 是否检查 0--手工确定 1--直接导入数据库中
* @return 错误的表格数据
* @throws JshException
*/
InputStream importExcel(File assetFile,int isCheck)throws JshException;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +1,15 @@
package com.jsh.service.asset;
import com.jsh.exception.AmsException;
import com.jsh.model.po.Asset;
import com.jsh.util.common.PageUtil;
public interface ReportIService
{
/**
* 查找报表数据
* @param asset
* @throws AmsException
*/
void find(PageUtil<Asset> asset,String reportType,String reportName)throws AmsException;
}
package com.jsh.service.asset;
import com.jsh.exception.JshException;
import com.jsh.model.po.Asset;
import com.jsh.util.common.PageUtil;
public interface ReportIService
{
/**
* 查找报表数据
* @param asset
* @throws JshException
*/
void find(PageUtil<Asset> asset,String reportType,String reportName)throws JshException;
}

View File

@ -1,23 +1,23 @@
package com.jsh.service.asset;
import com.jsh.dao.asset.ReportIDAO;
import com.jsh.exception.AmsException;
import com.jsh.model.po.Asset;
import com.jsh.util.common.PageUtil;
public class ReportService implements ReportIService
{
private ReportIDAO reportDao;
public void setReportDao(ReportIDAO reportDao)
{
this.reportDao = reportDao;
}
@Override
public void find(PageUtil<Asset> pageUtil, String reportType,String reportName) throws AmsException
{
reportDao.find(pageUtil, reportType,reportName);
}
}
package com.jsh.service.asset;
import com.jsh.dao.asset.ReportIDAO;
import com.jsh.exception.JshException;
import com.jsh.model.po.Asset;
import com.jsh.util.common.PageUtil;
public class ReportService implements ReportIService
{
private ReportIDAO reportDao;
public void setReportDao(ReportIDAO reportDao)
{
this.reportDao = reportDao;
}
@Override
public void find(PageUtil<Asset> pageUtil, String reportType,String reportName) throws JshException
{
reportDao.find(pageUtil, reportType,reportName);
}
}

View File

@ -1,16 +1,16 @@
package com.jsh.service.basic;
import com.jsh.base.BaseIService;
import com.jsh.exception.AmsException;
import com.jsh.model.po.Logdetails;
public interface LogIService extends BaseIService<Logdetails>
{
/**
* 增加
* @param t 对象
* @throws AmsException
*/
@Override
void save(Logdetails t);
}
package com.jsh.service.basic;
import com.jsh.base.BaseIService;
import com.jsh.exception.JshException;
import com.jsh.model.po.Logdetails;
public interface LogIService extends BaseIService<Logdetails>
{
/**
* 增加
* @param t 对象
* @throws JshException
*/
@Override
void save(Logdetails t);
}

View File

@ -1,15 +1,15 @@
package com.jsh.service.basic;
import com.jsh.base.BaseIService;
import com.jsh.exception.AmsException;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.common.PageUtil;
public interface UserBusinessIService extends BaseIService<UserBusiness>
{
/*
* 测试一下自定义hql语句
*/
void find(PageUtil<UserBusiness> userBusiness,String ceshi)throws AmsException;
}
package com.jsh.service.basic;
import com.jsh.base.BaseIService;
import com.jsh.exception.JshException;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.common.PageUtil;
public interface UserBusinessIService extends BaseIService<UserBusiness>
{
/*
* 测试一下自定义hql语句
*/
void find(PageUtil<UserBusiness> userBusiness,String ceshi)throws JshException;
}

View File

@ -1,32 +1,32 @@
package com.jsh.service.basic;
import com.jsh.base.BaseService;
import com.jsh.dao.basic.UserBusinessIDAO;
import com.jsh.exception.AmsException;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.common.PageUtil;
public class UserBusinessService extends BaseService<UserBusiness> implements UserBusinessIService
{
@SuppressWarnings("unused")
private UserBusinessIDAO userBusinessDao;
public void setUserBusinessDao(UserBusinessIDAO userBusinessDao)
{
this.userBusinessDao = userBusinessDao;
}
@Override
protected Class<UserBusiness> getEntityClass()
{
return UserBusiness.class;
}
@Override
public void find(PageUtil<UserBusiness> pageUtil, String ceshi) throws AmsException
{
userBusinessDao.find(pageUtil, ceshi);
}
}
package com.jsh.service.basic;
import com.jsh.base.BaseService;
import com.jsh.dao.basic.UserBusinessIDAO;
import com.jsh.exception.JshException;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.common.PageUtil;
public class UserBusinessService extends BaseService<UserBusiness> implements UserBusinessIService
{
@SuppressWarnings("unused")
private UserBusinessIDAO userBusinessDao;
public void setUserBusinessDao(UserBusinessIDAO userBusinessDao)
{
this.userBusinessDao = userBusinessDao;
}
@Override
protected Class<UserBusiness> getEntityClass()
{
return UserBusiness.class;
}
@Override
public void find(PageUtil<UserBusiness> pageUtil, String ceshi) throws JshException
{
userBusinessDao.find(pageUtil, ceshi);
}
}

View File

@ -1,33 +1,33 @@
package com.jsh.service.basic;
import com.jsh.base.BaseIService;
import com.jsh.exception.AmsException;
import com.jsh.model.po.Basicuser;
public interface UserIService extends BaseIService<Basicuser>
{
/**
* 判断用户名是否符合登录条件
* @param username 用户名 String password
* @return int 1用户名不存在 2密码不正确 3黑名单用户 4符合条件 5访问后台异常
*/
int validateUser(String username,String password)throws AmsException;
/**
* 获取用户信息
* @param username
* @return 用户信息
* @throws AmsException
*/
public Basicuser getUser(String username) throws AmsException;
/**
* 检查用户名称是否存在
* @param field 用户属性
* @param username 用户名称
* @param userID 供应商ID
* @return true==存在重名 false==不存在
* @throws AmsException
*/
Boolean checkIsNameExist(String field,String username,Long userID)throws AmsException;
}
package com.jsh.service.basic;
import com.jsh.base.BaseIService;
import com.jsh.exception.JshException;
import com.jsh.model.po.Basicuser;
public interface UserIService extends BaseIService<Basicuser>
{
/**
* 判断用户名是否符合登录条件
* @param username 用户名 String password
* @return int 1用户名不存在 2密码不正确 3黑名单用户 4符合条件 5访问后台异常
*/
int validateUser(String username,String password)throws JshException;
/**
* 获取用户信息
* @param username
* @return 用户信息
* @throws JshException
*/
public Basicuser getUser(String username) throws JshException;
/**
* 检查用户名称是否存在
* @param field 用户属性
* @param username 用户名称
* @param userID 供应商ID
* @return true==存在重名 false==不存在
* @throws JshException
*/
Boolean checkIsNameExist(String field,String username,Long userID)throws JshException;
}

View File

@ -1,114 +1,114 @@
package com.jsh.service.basic;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.jsh.base.BaseService;
import com.jsh.base.Log;
import com.jsh.constants.common.ExceptionCodeConstants;
import com.jsh.dao.basic.UserBusinessIDAO;
import com.jsh.dao.basic.UserIDAO;
import com.jsh.exception.AmsException;
import com.jsh.model.po.Basicuser;
import com.jsh.util.common.PageUtil;
public class UserService extends BaseService<Basicuser> implements UserIService
{
private PageUtil<Basicuser> pageUtil = new PageUtil<Basicuser>();
private Map<String,Object> condition = new HashMap<String,Object>();
private UserIDAO userDao;
@Override
public int validateUser(String username, String password)throws AmsException
{
try
{
//全局变量 每次使用前清除
condition.clear();
/**默认是可以登录的*/
List<Basicuser> list = null ;
try
{
condition.put("loginame_s_eq", username);
pageUtil.setAdvSearch(condition);
userDao.find(pageUtil);
list = pageUtil.getPageList();
}
catch (Exception e)
{
Log.errorFileSync(">>>>>>>>访问验证用户姓名是否存在后台信息异常",e);
return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION;
}
if(null !=list && list.size() == 0)
return ExceptionCodeConstants.UserExceptionCode.USER_NOT_EXIST ;
try
{
condition.put("loginame_s_eq", username);
condition.put("password_s_eq", password);
pageUtil.setAdvSearch(condition);
userDao.find(pageUtil);
list = pageUtil.getPageList();
}
catch (Exception e)
{
Log.errorFileSync(">>>>>>>>>>访问验证用户密码后台信息异常",e);
return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION;
}
if(null !=list && list.size() == 0)
return ExceptionCodeConstants.UserExceptionCode.USER_PASSWORD_ERROR;
return ExceptionCodeConstants.UserExceptionCode.USER_CONDITION_FIT;
}
catch (Exception e)
{
throw new AmsException("unknown exception",e);
}
}
@Override
public Basicuser getUser(String username) throws AmsException
{
//全局变量 每次使用前清除
condition.clear();
condition.put("loginame_s_eq", username);
pageUtil.setAdvSearch(condition);
userDao.find(pageUtil);
List<Basicuser> list = pageUtil.getPageList();
if(null != list && list.size() >0)
return list.get(0);
else
throw new AmsException("no username exist");
}
@Override
public Boolean checkIsNameExist(String field,String username, Long userID)throws AmsException
{
condition.clear();
condition.put(field + "_s_eq", username);
condition.put("id_n_neq", userID);
pageUtil.setAdvSearch(condition);
userDao.find(pageUtil);
List<Basicuser> dataList = pageUtil.getPageList();
if(null != dataList && dataList.size() > 0)
return true;
return false;
}
//==============spring注入等公共方法与业务无关=========================
public void setUserDao(UserIDAO userDao)
{
this.userDao = userDao;
}
@Override
protected Class<Basicuser> getEntityClass()
{
return Basicuser.class;
}
}
package com.jsh.service.basic;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.jsh.base.BaseService;
import com.jsh.base.Log;
import com.jsh.constants.common.ExceptionCodeConstants;
import com.jsh.dao.basic.UserBusinessIDAO;
import com.jsh.dao.basic.UserIDAO;
import com.jsh.exception.JshException;
import com.jsh.model.po.Basicuser;
import com.jsh.util.common.PageUtil;
public class UserService extends BaseService<Basicuser> implements UserIService
{
private PageUtil<Basicuser> pageUtil = new PageUtil<Basicuser>();
private Map<String,Object> condition = new HashMap<String,Object>();
private UserIDAO userDao;
@Override
public int validateUser(String username, String password)throws JshException
{
try
{
//全局变量 每次使用前清除
condition.clear();
/**默认是可以登录的*/
List<Basicuser> list = null ;
try
{
condition.put("loginame_s_eq", username);
pageUtil.setAdvSearch(condition);
userDao.find(pageUtil);
list = pageUtil.getPageList();
}
catch (Exception e)
{
Log.errorFileSync(">>>>>>>>访问验证用户姓名是否存在后台信息异常",e);
return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION;
}
if(null !=list && list.size() == 0)
return ExceptionCodeConstants.UserExceptionCode.USER_NOT_EXIST ;
try
{
condition.put("loginame_s_eq", username);
condition.put("password_s_eq", password);
pageUtil.setAdvSearch(condition);
userDao.find(pageUtil);
list = pageUtil.getPageList();
}
catch (Exception e)
{
Log.errorFileSync(">>>>>>>>>>访问验证用户密码后台信息异常",e);
return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION;
}
if(null !=list && list.size() == 0)
return ExceptionCodeConstants.UserExceptionCode.USER_PASSWORD_ERROR;
return ExceptionCodeConstants.UserExceptionCode.USER_CONDITION_FIT;
}
catch (Exception e)
{
throw new JshException("unknown exception",e);
}
}
@Override
public Basicuser getUser(String username) throws JshException
{
//全局变量 每次使用前清除
condition.clear();
condition.put("loginame_s_eq", username);
pageUtil.setAdvSearch(condition);
userDao.find(pageUtil);
List<Basicuser> list = pageUtil.getPageList();
if(null != list && list.size() >0)
return list.get(0);
else
throw new JshException("no username exist");
}
@Override
public Boolean checkIsNameExist(String field,String username, Long userID)throws JshException
{
condition.clear();
condition.put(field + "_s_eq", username);
condition.put("id_n_neq", userID);
pageUtil.setAdvSearch(condition);
userDao.find(pageUtil);
List<Basicuser> dataList = pageUtil.getPageList();
if(null != dataList && dataList.size() > 0)
return true;
return false;
}
//==============spring注入等公共方法与业务无关=========================
public void setUserDao(UserIDAO userDao)
{
this.userDao = userDao;
}
@Override
protected Class<Basicuser> getEntityClass()
{
return Basicuser.class;
}
}

View File

@ -1,15 +1,15 @@
package com.jsh.service.materials;
import com.jsh.base.BaseIService;
import com.jsh.exception.AmsException;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.common.PageUtil;
public interface DepotHeadIService extends BaseIService<DepotHead>
{
/*
* 获取MaxId
*/
void find(PageUtil<DepotHead> depotHead,String maxid)throws AmsException;
}
package com.jsh.service.materials;
import com.jsh.base.BaseIService;
import com.jsh.exception.JshException;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.common.PageUtil;
public interface DepotHeadIService extends BaseIService<DepotHead>
{
/*
* 获取MaxId
*/
void find(PageUtil<DepotHead> depotHead,String maxid)throws JshException;
}

View File

@ -1,32 +1,32 @@
package com.jsh.service.materials;
import com.jsh.base.BaseService;
import com.jsh.dao.materials.DepotHeadIDAO;
import com.jsh.exception.AmsException;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.common.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 AmsException
{
depotHeadDao.find(pageUtil, maxid);
}
}
package com.jsh.service.materials;
import com.jsh.base.BaseService;
import com.jsh.dao.materials.DepotHeadIDAO;
import com.jsh.exception.JshException;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.common.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);
}
}

View File

@ -1,26 +1,26 @@
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.exception.AmsException;
import com.jsh.model.po.Asset;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.DepotItem;
import com.jsh.util.common.PageUtil;
public interface DepotItemIService extends BaseIService<DepotItem>
{
void findByType(PageUtil<DepotItem> depotItem, String type, Long MId, String MonthTime,Boolean isPrev)throws AmsException;
void findOrderByMaterial(PageUtil<DepotItem> depotItem)throws AmsException;
/**
* 导出信息
* @return
*/
InputStream exmportExcel(String isAllPage,JSONArray dataArray)throws AmsException;
}
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.exception.JshException;
import com.jsh.model.po.Asset;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.DepotItem;
import com.jsh.util.common.PageUtil;
public interface DepotItemIService extends BaseIService<DepotItem>
{
void findByType(PageUtil<DepotItem> depotItem, String type, Long MId, String MonthTime,Boolean isPrev)throws JshException;
void findOrderByMaterial(PageUtil<DepotItem> depotItem)throws JshException;
/**
* 导出信息
* @return
*/
InputStream exmportExcel(String isAllPage,JSONArray dataArray)throws JshException;
}

View File

@ -1,124 +1,124 @@
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.constants.asset.AssetConstants;
import com.jsh.dao.materials.DepotItemIDAO;
import com.jsh.exception.AmsException;
import com.jsh.model.po.Asset;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.DepotItem;
import com.jsh.util.common.PageUtil;
import com.jsh.util.common.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 AmsException
{
depotItemDao.findByType(pageUtil, type, MId, MonthTime,isPrev);
}
@Override
public void findOrderByMaterial(PageUtil<DepotItem> pageUtil) throws AmsException
{
depotItemDao.findOrderByMaterial(pageUtil);
}
/**
* 导出Excel表格
*/
@Override
public InputStream exmportExcel(String isAllPage,JSONArray dataArray)throws AmsException
{
try
{
//将OutputStream转化为InputStream
ByteArrayOutputStream out = new ByteArrayOutputStream();
putDataOnOutputStream(out,dataArray);
return new ByteArrayInputStream(out.toByteArray());
}
catch (Exception e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>导出信息为excel表格异常", e);
throw new AmsException("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 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.constants.asset.AssetConstants;
import com.jsh.dao.materials.DepotItemIDAO;
import com.jsh.exception.JshException;
import com.jsh.model.po.Asset;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.DepotItem;
import com.jsh.util.common.PageUtil;
import com.jsh.util.common.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 findOrderByMaterial(PageUtil<DepotItem> pageUtil) throws JshException
{
depotItemDao.findOrderByMaterial(pageUtil);
}
/**
* 导出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);
}
}
}

View File

@ -1,135 +1,126 @@
/**
* HiTV
* com.suma.hitv.utils
* BeanFactoryUtil.java
* 版本信息V1.0
* 2011-12-30-下午01:25:00
* Copyright (c) 2000-2011北京数码视讯有限公司版权所有
*
*/
package com.jsh.util.common;
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 andy
* @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.common;
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
* @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);
}
}

View File

@ -1,198 +1,198 @@
package com.jsh.util.common;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
/**
* 分页工具类实现分页功能
* @author andy
* @version [版本号version01, 2012-1-25]
*/
@SuppressWarnings("serial")
public class PageUtil<E> implements Serializable
{
/**
* 总页数根据总数和单页显示个数进行计算
*/
private int totalPage = 0;
/**
* 总个数
*/
private int totalCount = 0 ;
/**
* 当前页码
*/
private int curPage = 1;
/**
* 每页显示个数
*/
private int pageSize = 10;
/**
* 是否为第一页
*/
private boolean isFirstPage = false;
/**
* 是否是最后一页
*/
private boolean isLastPage = false;
/**
* 是否有上一页
*/
private boolean hasPrevious = false;
/**
* 是否有下一页
*/
private boolean hasNext = false;
/**
* 返回页面list数组
*/
private List<E> pageList = new ArrayList<E>();
/**
* 页面搜索条件用map来实现
*/
private Map<String, Object> advSearch = new Hashtable<String, Object>();
public PageUtil()
{
}
public PageUtil(int totalCount,int pageSize,int curPage,Map<String, Object> adv)
{
init(totalCount,pageSize,curPage,adv);
}
/**
* 初始化页面显示参数
* @param totalCount 总数
* @param pageSize 页面显示个数
* @param curPage 当前页面
*/
public void init(int totalCount,int pageSize,int curPage,Map<String, Object> adv)
{
this.totalCount = totalCount;
this.pageSize = pageSize ;
this.curPage = curPage;
this.advSearch = adv;
//计算总页数
if(pageSize != 0)
{
this.totalPage = (totalCount+pageSize-1)/pageSize;
}
if(curPage <1)
{
this.curPage = 1;
}
if(curPage>this.totalPage)
{
this.curPage = this.totalPage;
}
if(curPage>0&&this.totalPage!=1&&curPage<this.totalPage)
{
this.hasNext = true ;
}
if(curPage>0&&this.totalPage!=1&&curPage>1&&curPage<=this.totalPage)
{
this.hasPrevious = true;
}
if(curPage == 1)
{
this.isFirstPage = true ;
}
if(curPage == this.totalPage)
{
this.isLastPage = true;
}
}
public int getTotalPage()
{
return totalPage;
}
public void setTotalPage(int totalPage)
{
this.totalPage = totalPage;
}
public int getTotalCount()
{
return totalCount;
}
public void setTotalCount(int totalCount)
{
this.totalCount = totalCount;
}
public int getCurPage()
{
return curPage;
}
public void setCurPage(int curPage)
{
this.curPage = curPage;
}
public int getPageSize()
{
return pageSize;
}
public void setPageSize(int pageSize)
{
this.pageSize = pageSize;
}
public boolean isFirstPage()
{
return isFirstPage;
}
public void setFirstPage(boolean isFirstPage)
{
this.isFirstPage = isFirstPage;
}
public boolean isLastPage()
{
return isLastPage;
}
public void setLastPage(boolean isLastPage)
{
this.isLastPage = isLastPage;
}
public boolean isHasPrevious()
{
return hasPrevious;
}
public void setHasPrevious(boolean hasPrevious)
{
this.hasPrevious = hasPrevious;
}
public boolean isHasNext()
{
return hasNext;
}
public void setHasNext(boolean hasNext)
{
this.hasNext = hasNext;
}
public List<E> getPageList()
{
return pageList;
}
public void setPageList(List<E> pageList)
{
this.pageList = pageList;
}
public Map<String, Object> getAdvSearch()
{
return advSearch;
}
public void setAdvSearch(Map<String, Object> advSearch)
{
this.advSearch = advSearch;
}
}
package com.jsh.util.common;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
/**
* 分页工具类实现分页功能
* @author jishenghua
* @version [版本号version01, 2012-1-25]
*/
@SuppressWarnings("serial")
public class PageUtil<E> implements Serializable
{
/**
* 总页数根据总数和单页显示个数进行计算
*/
private int totalPage = 0;
/**
* 总个数
*/
private int totalCount = 0 ;
/**
* 当前页码
*/
private int curPage = 1;
/**
* 每页显示个数
*/
private int pageSize = 10;
/**
* 是否为第一页
*/
private boolean isFirstPage = false;
/**
* 是否是最后一页
*/
private boolean isLastPage = false;
/**
* 是否有上一页
*/
private boolean hasPrevious = false;
/**
* 是否有下一页
*/
private boolean hasNext = false;
/**
* 返回页面list数组
*/
private List<E> pageList = new ArrayList<E>();
/**
* 页面搜索条件用map来实现
*/
private Map<String, Object> advSearch = new Hashtable<String, Object>();
public PageUtil()
{
}
public PageUtil(int totalCount,int pageSize,int curPage,Map<String, Object> adv)
{
init(totalCount,pageSize,curPage,adv);
}
/**
* 初始化页面显示参数
* @param totalCount 总数
* @param pageSize 页面显示个数
* @param curPage 当前页面
*/
public void init(int totalCount,int pageSize,int curPage,Map<String, Object> adv)
{
this.totalCount = totalCount;
this.pageSize = pageSize ;
this.curPage = curPage;
this.advSearch = adv;
//计算总页数
if(pageSize != 0)
{
this.totalPage = (totalCount+pageSize-1)/pageSize;
}
if(curPage <1)
{
this.curPage = 1;
}
if(curPage>this.totalPage)
{
this.curPage = this.totalPage;
}
if(curPage>0&&this.totalPage!=1&&curPage<this.totalPage)
{
this.hasNext = true ;
}
if(curPage>0&&this.totalPage!=1&&curPage>1&&curPage<=this.totalPage)
{
this.hasPrevious = true;
}
if(curPage == 1)
{
this.isFirstPage = true ;
}
if(curPage == this.totalPage)
{
this.isLastPage = true;
}
}
public int getTotalPage()
{
return totalPage;
}
public void setTotalPage(int totalPage)
{
this.totalPage = totalPage;
}
public int getTotalCount()
{
return totalCount;
}
public void setTotalCount(int totalCount)
{
this.totalCount = totalCount;
}
public int getCurPage()
{
return curPage;
}
public void setCurPage(int curPage)
{
this.curPage = curPage;
}
public int getPageSize()
{
return pageSize;
}
public void setPageSize(int pageSize)
{
this.pageSize = pageSize;
}
public boolean isFirstPage()
{
return isFirstPage;
}
public void setFirstPage(boolean isFirstPage)
{
this.isFirstPage = isFirstPage;
}
public boolean isLastPage()
{
return isLastPage;
}
public void setLastPage(boolean isLastPage)
{
this.isLastPage = isLastPage;
}
public boolean isHasPrevious()
{
return hasPrevious;
}
public void setHasPrevious(boolean hasPrevious)
{
this.hasPrevious = hasPrevious;
}
public boolean isHasNext()
{
return hasNext;
}
public void setHasNext(boolean hasNext)
{
this.hasNext = hasNext;
}
public List<E> getPageList()
{
return pageList;
}
public void setPageList(List<E> pageList)
{
this.pageList = pageList;
}
public Map<String, Object> getAdvSearch()
{
return advSearch;
}
public void setAdvSearch(Map<String, Object> advSearch)
{
this.advSearch = advSearch;
}
}

View File

@ -1,84 +1,84 @@
package com.jsh.util.common;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import com.jsh.base.Log;
/**
* 获取应用系统路径
* @author andy
*/
public class PathTool
{
/**
* 获取WEB-INF的绝对路径
* @return
*/
public static String getWebinfPath()
{
String webinfPath = "";
//获取URL对象
URL url = PathTool.class.getClassLoader().getResource("");
try
{
//获取路径
webinfPath = url.toURI().getPath();
//截取路径到WEB-INF结束
// webinfPath = path.substring(0, path.indexOf("/WEB-INF") + 8);
}
catch (URISyntaxException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>路径获取异常", e);
}
return webinfPath;
}
/**
* 获取webapp的绝对路径
* @return
*/
public static String getWebappPath()
{
//先获取工程路径
String projectPath = getProjectPath();
//获取工程路径的上级路径
File f = new File(projectPath);
//路径不存在就返回
if (!f.exists())
{
return projectPath;
}
else
{
//返回webapp路径
return f.getParent();
}
}
/**
* 获取工程的绝对路径
* @return
*/
public static String getProjectPath()
{
String projectPath = "";
//获取URL对象
URL url = PathTool.class.getClassLoader().getResource("");
String path = null;
try
{
//获取路径
path = url.toURI().getPath();
//截取webapp路径
projectPath = path.substring(0, path.indexOf("/WEB-INF"));
}
catch (URISyntaxException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>路径获取异常", e);
}
return projectPath;
}
}
package com.jsh.util.common;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import com.jsh.base.Log;
/**
* 获取应用系统路径
* @author jishenghua
*/
public class PathTool
{
/**
* 获取WEB-INF的绝对路径
* @return
*/
public static String getWebinfPath()
{
String webinfPath = "";
//获取URL对象
URL url = PathTool.class.getClassLoader().getResource("");
try
{
//获取路径
webinfPath = url.toURI().getPath();
//截取路径到WEB-INF结束
// webinfPath = path.substring(0, path.indexOf("/WEB-INF") + 8);
}
catch (URISyntaxException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>路径获取异常", e);
}
return webinfPath;
}
/**
* 获取webapp的绝对路径
* @return
*/
public static String getWebappPath()
{
//先获取工程路径
String projectPath = getProjectPath();
//获取工程路径的上级路径
File f = new File(projectPath);
//路径不存在就返回
if (!f.exists())
{
return projectPath;
}
else
{
//返回webapp路径
return f.getParent();
}
}
/**
* 获取工程的绝对路径
* @return
*/
public static String getProjectPath()
{
String projectPath = "";
//获取URL对象
URL url = PathTool.class.getClassLoader().getResource("");
String path = null;
try
{
//获取路径
path = url.toURI().getPath();
//截取webapp路径
projectPath = path.substring(0, path.indexOf("/WEB-INF"));
}
catch (URISyntaxException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>路径获取异常", e);
}
return projectPath;
}
}

View File

@ -1,127 +1,127 @@
package com.jsh.util.common;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* 根据搜索条件拼装成查询hql语句
* @author andy
*/
public class SearchConditionUtil
{
//拼接字符串的前缀空格字符串
private static final String emptyPrefix = " and ";
/**
* 根据搜索条件自动拼接成hql搜索语句
* @param condition 搜索条件 规则
* 1类型 n--数字 s--字符串
* 2属性 eq--等于 neq--不等于 like--'%XX%' llike--左像'%XX' rlike--右像'XX%' in--包含 gt--大于 gteq--大于等于 lt--小于 lteq--小于等于
* order--value desc asc gy-- group by
* 示例:
* Map<String,Object> condition = new HashMap<String,Object>();
* condition.put("supplier_s_like", "aaa");
* condition.put("contacts_s_llike", "186");
* condition.put("contacts_s_rlike", "186");
* condition.put("phonenum_s_eq", null);
* condition.put("email_n_neq", 23);
* condition.put("description_s_order", "desc");
* @return 封装后的字符串
*/
public static String getCondition(Map<String,Object> condition)
{
StringBuffer hql = new StringBuffer();
Set<String> key = condition.keySet();
String groupbyInfo = "";
String orderInfo = "";
for(String keyInfo:key)
{
/*
* 1数组为三个 第一个为对象实例的字段 第二个为字段类型 第三个为属性
* 2根据分解后的数组拼接搜索条件
*/
Object valueInfo = condition.get(keyInfo);
if(null != valueInfo &&valueInfo.toString().length()>0)
{
String[] searchCondition = keyInfo.split("_");
if(searchCondition[1].equals("n"))
hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + valueInfo);
else if(searchCondition[1].equals("s"))
{
if(searchCondition[2].equals("like"))
hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + "'%" + valueInfo + "%'");
else if(searchCondition[2].equals("llike"))
hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + "'%" + valueInfo + "'");
else if(searchCondition[2].equals("rlike"))
hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + "'" + valueInfo + "%'");
else if(searchCondition[2].equals("in"))
hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + "(" + valueInfo + ")");
else if(searchCondition[2].equals("order"))
orderInfo = " order by " + searchCondition[0] + " " + valueInfo;
else if(searchCondition[2].equals("gb"))
groupbyInfo = " group by " + searchCondition[0];
else
hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + "'" + valueInfo + "'");
}
}
}
return hql.append(groupbyInfo).append(orderInfo).toString();
}
/**
* 获取指定类型的符号
* 属性 eq--等于 neq--不等于 like-- in--包含 gt--大于 gteq--大于等于 lt--小于 lteq--小于等于 order--value desc asc
* @param type
* @return 类型字符串
*/
private static String getType(String type)
{
String typeStr = "";
if(type.equals("eq"))
typeStr = " = ";
else if(type.equals("neq"))
typeStr = " != ";
else if(type.equals("like"))
typeStr = " like ";
else if(type.equals("llike"))
typeStr = " like ";
else if(type.equals("rlike"))
typeStr = " like ";
else if(type.equals("in"))
typeStr = " in ";
else if(type.equals("gt"))
typeStr = " > ";
else if(type.equals("gteq"))
typeStr = " >= ";
else if(type.equals("lt"))
typeStr = " < ";
else if(type.equals("lteq"))
typeStr = " <= ";
else if(type.equals("order"))
typeStr = " order ";
else if(type.equals("gy"))
typeStr = " group by ";
else
typeStr = "unknown";
return typeStr;
}
public static void main(String[] args)
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("supplier_s_like", "aaa");
condition.put("contacts_s_llike", "186");
condition.put("contacts_s_rlike", "186");
condition.put("phonenum_s_eq", null);
condition.put("email_n_neq", 23);
condition.put("description_s_order", "desc");
condition.put("description_s_gb", "aaa");
//获取搜索条件拼接
System.out.println(getCondition(condition));
}
}
package com.jsh.util.common;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* 根据搜索条件拼装成查询hql语句
* @author jishenghua
*/
public class SearchConditionUtil
{
//拼接字符串的前缀空格字符串
private static final String emptyPrefix = " and ";
/**
* 根据搜索条件自动拼接成hql搜索语句
* @param condition 搜索条件 规则
* 1类型 n--数字 s--字符串
* 2属性 eq--等于 neq--不等于 like--'%XX%' llike--左像'%XX' rlike--右像'XX%' in--包含 gt--大于 gteq--大于等于 lt--小于 lteq--小于等于
* order--value desc asc gy-- group by
* 示例:
* Map<String,Object> condition = new HashMap<String,Object>();
* condition.put("supplier_s_like", "aaa");
* condition.put("contacts_s_llike", "186");
* condition.put("contacts_s_rlike", "186");
* condition.put("phonenum_s_eq", null);
* condition.put("email_n_neq", 23);
* condition.put("description_s_order", "desc");
* @return 封装后的字符串
*/
public static String getCondition(Map<String,Object> condition)
{
StringBuffer hql = new StringBuffer();
Set<String> key = condition.keySet();
String groupbyInfo = "";
String orderInfo = "";
for(String keyInfo:key)
{
/*
* 1数组为三个 第一个为对象实例的字段 第二个为字段类型 第三个为属性
* 2根据分解后的数组拼接搜索条件
*/
Object valueInfo = condition.get(keyInfo);
if(null != valueInfo &&valueInfo.toString().length()>0)
{
String[] searchCondition = keyInfo.split("_");
if(searchCondition[1].equals("n"))
hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + valueInfo);
else if(searchCondition[1].equals("s"))
{
if(searchCondition[2].equals("like"))
hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + "'%" + valueInfo + "%'");
else if(searchCondition[2].equals("llike"))
hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + "'%" + valueInfo + "'");
else if(searchCondition[2].equals("rlike"))
hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + "'" + valueInfo + "%'");
else if(searchCondition[2].equals("in"))
hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + "(" + valueInfo + ")");
else if(searchCondition[2].equals("order"))
orderInfo = " order by " + searchCondition[0] + " " + valueInfo;
else if(searchCondition[2].equals("gb"))
groupbyInfo = " group by " + searchCondition[0];
else
hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + "'" + valueInfo + "'");
}
}
}
return hql.append(groupbyInfo).append(orderInfo).toString();
}
/**
* 获取指定类型的符号
* 属性 eq--等于 neq--不等于 like-- in--包含 gt--大于 gteq--大于等于 lt--小于 lteq--小于等于 order--value desc asc
* @param type
* @return 类型字符串
*/
private static String getType(String type)
{
String typeStr = "";
if(type.equals("eq"))
typeStr = " = ";
else if(type.equals("neq"))
typeStr = " != ";
else if(type.equals("like"))
typeStr = " like ";
else if(type.equals("llike"))
typeStr = " like ";
else if(type.equals("rlike"))
typeStr = " like ";
else if(type.equals("in"))
typeStr = " in ";
else if(type.equals("gt"))
typeStr = " > ";
else if(type.equals("gteq"))
typeStr = " >= ";
else if(type.equals("lt"))
typeStr = " < ";
else if(type.equals("lteq"))
typeStr = " <= ";
else if(type.equals("order"))
typeStr = " order ";
else if(type.equals("gy"))
typeStr = " group by ";
else
typeStr = "unknown";
return typeStr;
}
public static void main(String[] args)
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("supplier_s_like", "aaa");
condition.put("contacts_s_llike", "186");
condition.put("contacts_s_rlike", "186");
condition.put("phonenum_s_eq", null);
condition.put("email_n_neq", 23);
condition.put("description_s_order", "desc");
condition.put("description_s_gb", "aaa");
//获取搜索条件拼接
System.out.println(getCondition(condition));
}
}

File diff suppressed because it is too large Load Diff