"mall-admin/vscode:/vscode.git/clone" did not exist on "d9c3d3c87b96d16802308a5b90bfe6e9399fc200"
Commit 07259995 authored by AlanGao's avatar AlanGao
Browse files

update

parent 458409b4
package com.jsh.action.materials; 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.BaseAction;
import com.jsh.base.Log; import com.jsh.base.Log;
import com.jsh.model.po.MaterialCategory;
import com.jsh.model.po.Logdetails; import com.jsh.model.po.Logdetails;
import com.jsh.model.po.MaterialCategory;
import com.jsh.model.vo.materials.MaterialCategoryModel; import com.jsh.model.vo.materials.MaterialCategoryModel;
import com.jsh.service.materials.MaterialCategoryIService; import com.jsh.service.materials.MaterialCategoryIService;
import com.jsh.util.PageUtil; import com.jsh.util.PageUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/* /*
* 商品类型管理 * 商品类型管理
* @author jishenghua qq:752718920 * @author jishenghua qq:752718920
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class MaterialCategoryAction extends BaseAction<MaterialCategoryModel> public class MaterialCategoryAction extends BaseAction<MaterialCategoryModel> {
{
private MaterialCategoryIService materialCategoryService; private MaterialCategoryIService materialCategoryService;
private MaterialCategoryModel model = new MaterialCategoryModel(); private MaterialCategoryModel model = new MaterialCategoryModel();
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({"rawtypes", "unchecked"})
public String getBasicData() public String getBasicData() {
{ Map<String, List> mapData = model.getShowModel().getMap();
Map<String,List> mapData = model.getShowModel().getMap(); PageUtil pageUtil = new PageUtil();
PageUtil pageUtil = new PageUtil();
pageUtil.setPageSize(0); pageUtil.setPageSize(0);
pageUtil.setCurPage(0); pageUtil.setCurPage(0);
try try {
{ Map<String, Object> condition = pageUtil.getAdvSearch();
Map<String,Object> condition = pageUtil.getAdvSearch();
condition.put("ParentId_n_eq", model.getParentId()); condition.put("ParentId_n_eq", model.getParentId());
condition.put("Id_n_neq", 1); condition.put("Id_n_neq", 1);
condition.put("Id_s_order", "asc"); condition.put("Id_s_order", "asc");
materialCategoryService.find(pageUtil); materialCategoryService.find(pageUtil);
mapData.put("materialCategoryList", pageUtil.getPageList()); mapData.put("materialCategoryList", pageUtil.getPageList());
} } catch (Exception e) {
catch (Exception e)
{
Log.errorFileSync(">>>>>>>>>>>>>查找商品类别信息异常", e); Log.errorFileSync(">>>>>>>>>>>>>查找商品类别信息异常", e);
model.getShowModel().setMsgTip("exceptoin"); model.getShowModel().setMsgTip("exceptoin");
} }
return SUCCESS; return SUCCESS;
} }
/** /**
* 增加商品类别 * 增加商品类别
* @return *
*/ * @return
public void create() */
{ public void create() {
Log.infoFileSync("==================开始调用增加商品类别信息方法create()==================="); Log.infoFileSync("==================开始调用增加商品类别信息方法create()===================");
Boolean flag = false; Boolean flag = false;
try try {
{ MaterialCategory materialCategory = new MaterialCategory();
MaterialCategory materialCategory = new MaterialCategory(); materialCategory.setMaterialCategory(new MaterialCategory(model.getParentId()));
materialCategory.setMaterialCategory(new MaterialCategory(model.getParentId()));
materialCategory.setCategoryLevel(model.getCategoryLevel());
materialCategory.setCategoryLevel(model.getCategoryLevel()); materialCategory.setName(model.getName());
materialCategory.setName(model.getName()); materialCategoryService.create(materialCategory);
materialCategoryService.create(materialCategory);
//========标识位===========
//========标识位=========== flag = true;
flag = true; //记录操作日志使用
//记录操作日志使用 tipMsg = "成功";
tipMsg = "成功";
tipType = 0; tipType = 0;
} } catch (DataAccessException e) {
catch (DataAccessException e) Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加商品类别信息异常", e);
{ flag = false;
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加商品类别信息异常", e); tipMsg = "失败";
flag = false;
tipMsg = "失败";
tipType = 1; tipType = 1;
} } finally {
finally try {
{
try
{
toClient(flag.toString()); toClient(flag.toString());
} } catch (IOException e) {
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>增加商品类别信息回写客户端结果异常", e); Log.errorFileSync(">>>>>>>>>>>>增加商品类别信息回写客户端结果异常", e);
} }
} }
logService.create(new Logdetails(getUser(), "增加商品类别", model.getClientIp(), logService.create(new Logdetails(getUser(), "增加商品类别", model.getClientIp(),
new Timestamp(System.currentTimeMillis()) new Timestamp(System.currentTimeMillis())
, tipType, "增加商品类别名称为 "+ model.getName() + " " + tipMsg + "!", "增加商品类别" + tipMsg)); , tipType, "增加商品类别名称为 " + model.getName() + " " + tipMsg + "!", "增加商品类别" + tipMsg));
Log.infoFileSync("==================结束调用增加商品类别方法create()==================="); Log.infoFileSync("==================结束调用增加商品类别方法create()===================");
} }
/** /**
* 删除商品类别 * 删除商品类别
* @return *
*/ * @return
public String delete() */
{ public String delete() {
Log.infoFileSync("====================开始调用删除商品类别信息方法delete()================"); Log.infoFileSync("====================开始调用删除商品类别信息方法delete()================");
try try {
{ materialCategoryService.delete(model.getMaterialCategoryID());
materialCategoryService.delete(model.getMaterialCategoryID());
tipMsg = "成功"; tipMsg = "成功";
tipType = 0; tipType = 0;
} } catch (DataAccessException e) {
catch (DataAccessException e) Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getMaterialCategoryID() + " 的商品类别异常", e);
{ tipMsg = "失败";
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getMaterialCategoryID() + " 的商品类别异常", e);
tipMsg = "失败";
tipType = 1; tipType = 1;
} }
model.getShowModel().setMsgTip(tipMsg); model.getShowModel().setMsgTip(tipMsg);
logService.create(new Logdetails(getUser(), "删除商品类别", model.getClientIp(), logService.create(new Logdetails(getUser(), "删除商品类别", model.getClientIp(),
new Timestamp(System.currentTimeMillis()) new Timestamp(System.currentTimeMillis())
, tipType, "删除商品类别ID为 "+ model.getMaterialCategoryID() + " " + tipMsg + "!", "删除商品类别" + tipMsg)); , tipType, "删除商品类别ID为 " + model.getMaterialCategoryID() + " " + tipMsg + "!", "删除商品类别" + tipMsg));
Log.infoFileSync("====================结束调用删除商品类别信息方法delete()================"); Log.infoFileSync("====================结束调用删除商品类别信息方法delete()================");
return SUCCESS; return SUCCESS;
} }
/** /**
* 更新商品类别 * 更新商品类别
* @return *
*/ * @return
public void update() */
{ public void update() {
Boolean flag = false; Boolean flag = false;
try try {
{ MaterialCategory materialCategory = materialCategoryService.get(model.getMaterialCategoryID());
MaterialCategory materialCategory = materialCategoryService.get(model.getMaterialCategoryID()); materialCategory.setMaterialCategory(new MaterialCategory(model.getParentId()));
materialCategory.setMaterialCategory(new MaterialCategory(model.getParentId()));
materialCategory.setCategoryLevel(model.getCategoryLevel());
materialCategory.setCategoryLevel(model.getCategoryLevel()); materialCategory.setName(model.getName());
materialCategory.setName(model.getName()); materialCategoryService.update(materialCategory);
materialCategoryService.update(materialCategory);
flag = true; flag = true;
tipMsg = "成功"; tipMsg = "成功";
tipType = 0; tipType = 0;
} } catch (DataAccessException e) {
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>修改商品类别ID为 : " + model.getMaterialCategoryID() + "信息失败", e); Log.errorFileSync(">>>>>>>>>>>>>修改商品类别ID为 : " + model.getMaterialCategoryID() + "信息失败", e);
flag = false; flag = false;
tipMsg = "失败"; tipMsg = "失败";
tipType = 1; tipType = 1;
} } finally {
finally try {
{
try
{
toClient(flag.toString()); toClient(flag.toString());
} } catch (IOException e) {
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>修改商品类别回写客户端结果异常", e); Log.errorFileSync(">>>>>>>>>>>>修改商品类别回写客户端结果异常", e);
} }
} }
logService.create(new Logdetails(getUser(), "更新商品类别", model.getClientIp(), logService.create(new Logdetails(getUser(), "更新商品类别", model.getClientIp(),
new Timestamp(System.currentTimeMillis()) new Timestamp(System.currentTimeMillis())
, tipType, "更新商品类别ID为 "+ model.getMaterialCategoryID() + " " + tipMsg + "!", "更新商品类别" + tipMsg)); , tipType, "更新商品类别ID为 " + model.getMaterialCategoryID() + " " + tipMsg + "!", "更新商品类别" + tipMsg));
} }
/** /**
* 批量删除指定ID商品类别 * 批量删除指定ID商品类别
* @return *
*/ * @return
public String batchDelete() */
{ public String batchDelete() {
try try {
{ materialCategoryService.batchDelete(model.getMaterialCategoryIDs());
materialCategoryService.batchDelete(model.getMaterialCategoryIDs());
model.getShowModel().setMsgTip("成功"); model.getShowModel().setMsgTip("成功");
//记录操作日志使用 //记录操作日志使用
tipMsg = "成功"; tipMsg = "成功";
tipType = 0; tipType = 0;
} } catch (DataAccessException e) {
catch (DataAccessException e) Log.errorFileSync(">>>>>>>>>>>批量删除商品类别ID为:" + model.getMaterialCategoryIDs() + "信息异常", e);
{ tipMsg = "失败";
Log.errorFileSync(">>>>>>>>>>>批量删除商品类别ID为:" + model.getMaterialCategoryIDs() + "信息异常", e);
tipMsg = "失败";
tipType = 1; tipType = 1;
} }
logService.create(new Logdetails(getUser(), "批量删除商品类别", model.getClientIp(), logService.create(new Logdetails(getUser(), "批量删除商品类别", model.getClientIp(),
new Timestamp(System.currentTimeMillis()) new Timestamp(System.currentTimeMillis())
, tipType, "批量删除商品类别ID为 "+ model.getMaterialCategoryIDs() + " " + tipMsg + "!", "批量删除商品类别" + tipMsg)); , tipType, "批量删除商品类别ID为 " + model.getMaterialCategoryIDs() + " " + tipMsg + "!", "批量删除商品类别" + tipMsg));
return SUCCESS; return SUCCESS;
} }
/** /**
* 查找商品类别信息 * 查找商品类别信息
* @return *
*/ * @return
public void findBy() */
{ public void findBy() {
try try {
{ PageUtil<MaterialCategory> pageUtil = new PageUtil<MaterialCategory>();
PageUtil<MaterialCategory> pageUtil = new PageUtil<MaterialCategory>();
pageUtil.setPageSize(model.getPageSize()); pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo()); pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition()); pageUtil.setAdvSearch(getCondition());
materialCategoryService.find(pageUtil); materialCategoryService.find(pageUtil);
List<MaterialCategory> dataList = pageUtil.getPageList(); List<MaterialCategory> dataList = pageUtil.getPageList();
//开始拼接json数据 //开始拼接json数据
// {"total":28,"rows":[ // {"total":28,"rows":[
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"} // {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
...@@ -218,10 +192,8 @@ public class MaterialCategoryAction extends BaseAction<MaterialCategoryModel> ...@@ -218,10 +192,8 @@ public class MaterialCategoryAction extends BaseAction<MaterialCategoryModel>
outer.put("total", pageUtil.getTotalCount()); outer.put("total", pageUtil.getTotalCount());
//存放数据json数组 //存放数据json数组
JSONArray dataArray = new JSONArray(); JSONArray dataArray = new JSONArray();
if(null != dataList) if (null != dataList) {
{ for (MaterialCategory materialCategory : dataList) {
for(MaterialCategory materialCategory:dataList)
{
JSONObject item = new JSONObject(); JSONObject item = new JSONObject();
item.put("Id", materialCategory.getId()); item.put("Id", materialCategory.getId());
item.put("ParentId", materialCategory.getMaterialCategory().getId()); item.put("ParentId", materialCategory.getMaterialCategory().getId());
...@@ -235,19 +207,16 @@ public class MaterialCategoryAction extends BaseAction<MaterialCategoryModel> ...@@ -235,19 +207,16 @@ public class MaterialCategoryAction extends BaseAction<MaterialCategoryModel>
outer.put("rows", dataArray); outer.put("rows", dataArray);
//回写查询结果 //回写查询结果
toClient(outer.toString()); toClient(outer.toString());
} } catch (DataAccessException e) {
catch (DataAccessException e) Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找商品类别信息异常", e);
{ } catch (IOException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找商品类别信息异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询商品类别信息结果异常", e); Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询商品类别信息结果异常", e);
} }
} }
/** /**
* 根据id来查询商品名称 * 根据id来查询商品名称
*
* @return * @return
*/ */
public void findById() { public void findById() {
...@@ -257,35 +226,31 @@ public class MaterialCategoryAction extends BaseAction<MaterialCategoryModel> ...@@ -257,35 +226,31 @@ public class MaterialCategoryAction extends BaseAction<MaterialCategoryModel>
materialCategoryService.find(pageUtil); materialCategoryService.find(pageUtil);
List<MaterialCategory> dataList = pageUtil.getPageList(); List<MaterialCategory> dataList = pageUtil.getPageList();
JSONObject outer = new JSONObject(); JSONObject outer = new JSONObject();
if(null != dataList) { if (null != dataList) {
for(MaterialCategory materialCategory : dataList) { for (MaterialCategory materialCategory : dataList) {
outer.put("name", materialCategory.getName()); outer.put("name", materialCategory.getName());
outer.put("parentId", materialCategory.getMaterialCategory().getId()); outer.put("parentId", materialCategory.getMaterialCategory().getId());
} }
} }
//回写查询结果 //回写查询结果
toClient(outer.toString()); toClient(outer.toString());
} } catch (DataAccessException e) {
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找商品类别信息异常", e); Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找商品类别信息异常", e);
} } catch (IOException e) {
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询商品类别信息结果异常", e); Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询商品类别信息结果异常", e);
} }
} }
/** /**
* 拼接搜索条件 * 拼接搜索条件
* @return *
*/ * @return
private Map<String,Object> getCondition() */
{ private Map<String, Object> getCondition() {
/** /**
* 拼接搜索条件 * 拼接搜索条件
*/ */
Map<String,Object> condition = new HashMap<String,Object>(); Map<String, Object> condition = new HashMap<String, Object>();
condition.put("Name_s_like", model.getName()); condition.put("Name_s_like", model.getName());
condition.put("ParentId_n_eq", model.getParentId()); condition.put("ParentId_n_eq", model.getParentId());
condition.put("Id_n_neq", 1); condition.put("Id_n_neq", 1);
...@@ -295,25 +260,25 @@ public class MaterialCategoryAction extends BaseAction<MaterialCategoryModel> ...@@ -295,25 +260,25 @@ public class MaterialCategoryAction extends BaseAction<MaterialCategoryModel>
/** /**
* 拼接搜索条件 * 拼接搜索条件
*
* @return * @return
*/ */
private Map<String,Object> getConditionById(){ private Map<String, Object> getConditionById() {
/** /**
* 拼接搜索条件 * 拼接搜索条件
*/ */
Map<String,Object> condition = new HashMap<String,Object>(); Map<String, Object> condition = new HashMap<String, Object>();
condition.put("Id_n_eq", model.getMaterialCategoryID()); condition.put("Id_n_eq", model.getMaterialCategoryID());
return condition; return condition;
} }
//=============以下spring注入以及Model驱动公共方法,与Action处理无关================== //=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
@Override @Override
public MaterialCategoryModel getModel() public MaterialCategoryModel getModel() {
{ return model;
return model; }
}
public void setMaterialCategoryService(MaterialCategoryIService materialCategoryService) public void setMaterialCategoryService(MaterialCategoryIService materialCategoryService) {
{
this.materialCategoryService = materialCategoryService; this.materialCategoryService = materialCategoryService;
} }
} }
...@@ -20,19 +20,19 @@ import java.util.Map; ...@@ -20,19 +20,19 @@ import java.util.Map;
/* /*
* 商品属性 * 商品属性
* @author ji s h e n g hua qq:75 27 18 920 * @author ji s h e n g hua qq:75 27 18 920
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class MaterialPropertyAction extends BaseAction<MaterialPropertyModel> public class MaterialPropertyAction extends BaseAction<MaterialPropertyModel> {
{
private MaterialPropertyIService materialPropertyService; private MaterialPropertyIService materialPropertyService;
private MaterialPropertyModel model = new MaterialPropertyModel(); private MaterialPropertyModel model = new MaterialPropertyModel();
/** /**
* 更新商品属性 * 更新商品属性
* @return *
*/ * @return
public void update() { */
Boolean flag = false; public void update() {
Boolean flag = false;
try { try {
MaterialProperty materialProperty = materialPropertyService.get(model.getId()); MaterialProperty materialProperty = materialPropertyService.get(model.getId());
materialProperty.setNativeName(model.getNativeName()); materialProperty.setNativeName(model.getNativeName());
...@@ -40,37 +40,35 @@ public class MaterialPropertyAction extends BaseAction<MaterialPropertyModel> ...@@ -40,37 +40,35 @@ public class MaterialPropertyAction extends BaseAction<MaterialPropertyModel>
materialProperty.setSort(model.getSort()); materialProperty.setSort(model.getSort());
materialProperty.setAnotherName(model.getAnotherName()); materialProperty.setAnotherName(model.getAnotherName());
materialPropertyService.update(materialProperty); materialPropertyService.update(materialProperty);
flag = true; flag = true;
tipMsg = "成功"; tipMsg = "成功";
tipType = 0; tipType = 0;
} } catch (DataAccessException e) {
catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>>>修改商品属性ID为 : " + model.getId() + "失败", e); Log.errorFileSync(">>>>>>>>>>>>>修改商品属性ID为 : " + model.getId() + "失败", e);
flag = false; flag = false;
tipMsg = "失败"; tipMsg = "失败";
tipType = 1; tipType = 1;
} } finally {
finally {
try { try {
toClient(flag.toString()); toClient(flag.toString());
} } catch (IOException e) {
catch (IOException e) {
Log.errorFileSync(">>>>>>>>>>>>修改商品属性回写客户端结果异常", e); Log.errorFileSync(">>>>>>>>>>>>修改商品属性回写客户端结果异常", e);
} }
} }
logService.create(new Logdetails(getUser(), "更新商品属性", model.getClientIp(), logService.create(new Logdetails(getUser(), "更新商品属性", model.getClientIp(),
new Timestamp(System.currentTimeMillis()) new Timestamp(System.currentTimeMillis())
, tipType, "更新商品属性ID为 "+ model.getId() + " " + tipMsg + "!", "更新商品属性" + tipMsg)); , tipType, "更新商品属性ID为 " + model.getId() + " " + tipMsg + "!", "更新商品属性" + tipMsg));
} }
/** /**
* 查找商品属性 * 查找商品属性
* @return *
*/ * @return
*/
public void findBy() { public void findBy() {
try { try {
PageUtil<MaterialProperty> pageUtil = new PageUtil<MaterialProperty>(); PageUtil<MaterialProperty> pageUtil = new PageUtil<MaterialProperty>();
pageUtil.setPageSize(0); pageUtil.setPageSize(0);
pageUtil.setCurPage(0); pageUtil.setCurPage(0);
pageUtil.setAdvSearch(getCondition()); pageUtil.setAdvSearch(getCondition());
...@@ -81,8 +79,8 @@ public class MaterialPropertyAction extends BaseAction<MaterialPropertyModel> ...@@ -81,8 +79,8 @@ public class MaterialPropertyAction extends BaseAction<MaterialPropertyModel>
outer.put("total", pageUtil.getTotalCount()); outer.put("total", pageUtil.getTotalCount());
//存放数据json数组 //存放数据json数组
JSONArray dataArray = new JSONArray(); JSONArray dataArray = new JSONArray();
if(null != dataList) { if (null != dataList) {
for(MaterialProperty materialProperty:dataList) { for (MaterialProperty materialProperty : dataList) {
JSONObject item = new JSONObject(); JSONObject item = new JSONObject();
item.put("id", materialProperty.getId()); item.put("id", materialProperty.getId());
item.put("nativeName", materialProperty.getNativeName()); item.put("nativeName", materialProperty.getNativeName());
...@@ -95,38 +93,35 @@ public class MaterialPropertyAction extends BaseAction<MaterialPropertyModel> ...@@ -95,38 +93,35 @@ public class MaterialPropertyAction extends BaseAction<MaterialPropertyModel>
outer.put("rows", dataArray); outer.put("rows", dataArray);
//回写查询结果 //回写查询结果
toClient(outer.toString()); toClient(outer.toString());
} } catch (DataAccessException e) {
catch (DataAccessException e) Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找商品属性异常", e);
{ } catch (IOException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找商品属性异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询商品属性结果异常", e); Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询商品属性结果异常", e);
} }
} }
/** /**
* 拼接搜索条件 * 拼接搜索条件
* @return *
*/ * @return
private Map<String,Object> getCondition() */
{ private Map<String, Object> getCondition() {
/** /**
* 拼接搜索条件 * 拼接搜索条件
*/ */
Map<String,Object> condition = new HashMap<String,Object>(); Map<String, Object> condition = new HashMap<String, Object>();
condition.put("nativeName_s_like", model.getNativeName()); condition.put("nativeName_s_like", model.getNativeName());
condition.put("sort_s_order", "asc"); condition.put("sort_s_order", "asc");
return condition; return condition;
} }
//=============以下spring注入以及Model驱动公共方法,与Action处理无关================== //=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
@Override @Override
public MaterialPropertyModel getModel() { public MaterialPropertyModel getModel() {
return model; return model;
} }
public void setMaterialPropertyService(MaterialPropertyIService materialPropertyService) {
public void setMaterialPropertyService(MaterialPropertyIService materialPropertyService) {
this.materialPropertyService = materialPropertyService; this.materialPropertyService = materialPropertyService;
} }
} }
package com.jsh.action.materials; 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.BaseAction;
import com.jsh.base.Log; import com.jsh.base.Log;
import com.jsh.model.po.Depot;
import com.jsh.model.po.Person;
import com.jsh.model.po.Logdetails; import com.jsh.model.po.Logdetails;
import com.jsh.model.po.Person;
import com.jsh.model.vo.materials.PersonModel; import com.jsh.model.vo.materials.PersonModel;
import com.jsh.service.materials.PersonIService; import com.jsh.service.materials.PersonIService;
import com.jsh.util.PageUtil; import com.jsh.util.PageUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/* /*
* 经手人管理 * 经手人管理
* @author jishenghua qq:752718920 * @author jishenghua qq:752718920
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class PersonAction extends BaseAction<PersonModel> public class PersonAction extends BaseAction<PersonModel> {
{
private PersonIService personService; private PersonIService personService;
private PersonModel model = new PersonModel(); private PersonModel model = new PersonModel();
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({"rawtypes", "unchecked"})
public String getBasicData() public String getBasicData() {
{ Map<String, List> mapData = model.getShowModel().getMap();
Map<String,List> mapData = model.getShowModel().getMap(); PageUtil pageUtil = new PageUtil();
PageUtil pageUtil = new PageUtil();
pageUtil.setPageSize(0); pageUtil.setPageSize(0);
pageUtil.setCurPage(0); pageUtil.setCurPage(0);
try try {
{ Map<String, Object> condition = pageUtil.getAdvSearch();
Map<String,Object> condition = pageUtil.getAdvSearch();
condition.put("Id_s_order", "asc"); condition.put("Id_s_order", "asc");
personService.find(pageUtil); personService.find(pageUtil);
mapData.put("personList", pageUtil.getPageList()); mapData.put("personList", pageUtil.getPageList());
} } catch (Exception e) {
catch (Exception e)
{
Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e); Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e);
model.getShowModel().setMsgTip("exceptoin"); model.getShowModel().setMsgTip("exceptoin");
} }
return SUCCESS; return SUCCESS;
} }
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({"rawtypes", "unchecked"})
public String getPersonByType() public String getPersonByType() {
{ Map<String, List> mapData = model.getShowModel().getMap();
Map<String,List> mapData = model.getShowModel().getMap(); PageUtil pageUtil = new PageUtil();
PageUtil pageUtil = new PageUtil();
pageUtil.setPageSize(0); pageUtil.setPageSize(0);
pageUtil.setCurPage(0); pageUtil.setCurPage(0);
try try {
{ Map<String, Object> condition = pageUtil.getAdvSearch();
Map<String,Object> condition = pageUtil.getAdvSearch();
condition.put("Type_s_eq", model.getType()); condition.put("Type_s_eq", model.getType());
condition.put("Id_s_order", "asc"); condition.put("Id_s_order", "asc");
personService.find(pageUtil); personService.find(pageUtil);
mapData.put("personList", pageUtil.getPageList()); mapData.put("personList", pageUtil.getPageList());
} } catch (Exception e) {
catch (Exception e)
{
Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e); Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e);
model.getShowModel().setMsgTip("exceptoin"); model.getShowModel().setMsgTip("exceptoin");
} }
...@@ -73,31 +65,30 @@ public class PersonAction extends BaseAction<PersonModel> ...@@ -73,31 +65,30 @@ public class PersonAction extends BaseAction<PersonModel>
/** /**
* 根据类型获取经手人信息 1-业务员,2-仓管员,3-财务员 * 根据类型获取经手人信息 1-业务员,2-仓管员,3-财务员
*
* @return * @return
*/ */
public void getPersonByNumType() { public void getPersonByNumType() {
try { try {
PageUtil<Person> pageUtil = new PageUtil<Person>(); PageUtil<Person> pageUtil = new PageUtil<Person>();
pageUtil.setPageSize(0); pageUtil.setPageSize(0);
pageUtil.setCurPage(0); pageUtil.setCurPage(0);
Map<String,Object> condition = pageUtil.getAdvSearch(); Map<String, Object> condition = pageUtil.getAdvSearch();
String type = ""; String type = "";
if(model.getType().equals("1")){ if (model.getType().equals("1")) {
type = "业务员"; type = "业务员";
} } else if (model.getType().equals("2")) {
else if(model.getType().equals("2")){
type = "仓管员"; type = "仓管员";
} } else if (model.getType().equals("3")) {
else if(model.getType().equals("3")){
type = "财务员"; type = "财务员";
} }
condition.put("Type_s_eq",type); condition.put("Type_s_eq", type);
condition.put("Id_s_order", "asc"); condition.put("Id_s_order", "asc");
personService.find(pageUtil); personService.find(pageUtil);
List<Person> dataList = pageUtil.getPageList(); List<Person> dataList = pageUtil.getPageList();
JSONArray dataArray = new JSONArray(); JSONArray dataArray = new JSONArray();
if(null != dataList) { if (null != dataList) {
for(Person person:dataList){ for (Person person : dataList) {
JSONObject item = new JSONObject(); JSONObject item = new JSONObject();
item.put("id", person.getId()); item.put("id", person.getId());
item.put("name", person.getName()); item.put("name", person.getName());
...@@ -106,212 +97,184 @@ public class PersonAction extends BaseAction<PersonModel> ...@@ -106,212 +97,184 @@ public class PersonAction extends BaseAction<PersonModel>
} }
//回写查询结果 //回写查询结果
toClient(dataArray.toString()); toClient(dataArray.toString());
} } catch (DataAccessException e) {
catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>查找信息异常", e); Log.errorFileSync(">>>>>>>>>查找信息异常", e);
} } catch (IOException e) {
catch (IOException e) {
Log.errorFileSync(">>>>>>>>>回写查询信息结果异常", e); Log.errorFileSync(">>>>>>>>>回写查询信息结果异常", e);
} }
} }
/** /**
* 根据Id获取经手人信息 * 根据Id获取经手人信息
*
* @return * @return
*/ */
public void getPersonByIds() { public void getPersonByIds() {
try { try {
PageUtil<Person> pageUtil = new PageUtil<Person>(); PageUtil<Person> pageUtil = new PageUtil<Person>();
pageUtil.setPageSize(0); pageUtil.setPageSize(0);
pageUtil.setCurPage(0); pageUtil.setCurPage(0);
Map<String,Object> condition = pageUtil.getAdvSearch(); Map<String, Object> condition = pageUtil.getAdvSearch();
condition.put("Id_s_in", model.getPersonIDs()); condition.put("Id_s_in", model.getPersonIDs());
condition.put("Id_s_order", "asc"); condition.put("Id_s_order", "asc");
personService.find(pageUtil); personService.find(pageUtil);
List<Person> dataList = pageUtil.getPageList(); List<Person> dataList = pageUtil.getPageList();
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
if(null != dataList) { if (null != dataList) {
for(Person person:dataList){ for (Person person : dataList) {
sb.append(person.getName() + " "); sb.append(person.getName() + " ");
} }
} }
//回写查询结果 //回写查询结果
toClient(sb.toString()); toClient(sb.toString());
} } catch (DataAccessException e) {
catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>查找信息异常", e); Log.errorFileSync(">>>>>>>>>查找信息异常", e);
} } catch (IOException e) {
catch (IOException e) {
Log.errorFileSync(">>>>>>>>>回写查询信息结果异常", e); Log.errorFileSync(">>>>>>>>>回写查询信息结果异常", e);
} }
} }
/** /**
* 增加经手人 * 增加经手人
* @return *
*/ * @return
public void create() */
{ public void create() {
Log.infoFileSync("==================开始调用增加经手人信息方法create()==================="); Log.infoFileSync("==================开始调用增加经手人信息方法create()===================");
Boolean flag = false; Boolean flag = false;
try try {
{ Person person = new Person();
Person person = new Person();
person.setType(model.getType());
person.setType(model.getType()); person.setName(model.getName());
person.setName(model.getName()); personService.create(person);
personService.create(person);
//========标识位===========
//========标识位=========== flag = true;
flag = true; //记录操作日志使用
//记录操作日志使用 tipMsg = "成功";
tipMsg = "成功";
tipType = 0; tipType = 0;
} } catch (DataAccessException e) {
catch (DataAccessException e) Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加经手人信息异常", e);
{ flag = false;
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加经手人信息异常", e); tipMsg = "失败";
flag = false;
tipMsg = "失败";
tipType = 1; tipType = 1;
} } finally {
finally try {
{
try
{
toClient(flag.toString()); toClient(flag.toString());
} } catch (IOException e) {
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>增加经手人信息回写客户端结果异常", e); Log.errorFileSync(">>>>>>>>>>>>增加经手人信息回写客户端结果异常", e);
} }
} }
logService.create(new Logdetails(getUser(), "增加经手人", model.getClientIp(), logService.create(new Logdetails(getUser(), "增加经手人", model.getClientIp(),
new Timestamp(System.currentTimeMillis()) new Timestamp(System.currentTimeMillis())
, tipType, "增加经手人名称为 "+ model.getName() + " " + tipMsg + "!", "增加经手人" + tipMsg)); , tipType, "增加经手人名称为 " + model.getName() + " " + tipMsg + "!", "增加经手人" + tipMsg));
Log.infoFileSync("==================结束调用增加经手人方法create()==================="); Log.infoFileSync("==================结束调用增加经手人方法create()===================");
} }
/** /**
* 删除经手人 * 删除经手人
* @return *
*/ * @return
public String delete() */
{ public String delete() {
Log.infoFileSync("====================开始调用删除经手人信息方法delete()================"); Log.infoFileSync("====================开始调用删除经手人信息方法delete()================");
try try {
{ personService.delete(model.getPersonID());
personService.delete(model.getPersonID());
tipMsg = "成功"; tipMsg = "成功";
tipType = 0; tipType = 0;
} } catch (DataAccessException e) {
catch (DataAccessException e) Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getPersonID() + " 的经手人异常", e);
{ tipMsg = "失败";
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getPersonID() + " 的经手人异常", e);
tipMsg = "失败";
tipType = 1; tipType = 1;
} }
model.getShowModel().setMsgTip(tipMsg); model.getShowModel().setMsgTip(tipMsg);
logService.create(new Logdetails(getUser(), "删除经手人", model.getClientIp(), logService.create(new Logdetails(getUser(), "删除经手人", model.getClientIp(),
new Timestamp(System.currentTimeMillis()) new Timestamp(System.currentTimeMillis())
, tipType, "删除经手人ID为 "+ model.getPersonID() + " " + tipMsg + "!", "删除经手人" + tipMsg)); , tipType, "删除经手人ID为 " + model.getPersonID() + " " + tipMsg + "!", "删除经手人" + tipMsg));
Log.infoFileSync("====================结束调用删除经手人信息方法delete()================"); Log.infoFileSync("====================结束调用删除经手人信息方法delete()================");
return SUCCESS; return SUCCESS;
} }
/** /**
* 更新经手人 * 更新经手人
* @return *
*/ * @return
public void update() */
{ public void update() {
Boolean flag = false; Boolean flag = false;
try try {
{ Person person = personService.get(model.getPersonID());
Person person = personService.get(model.getPersonID());
person.setType(model.getType());
person.setType(model.getType()); person.setName(model.getName());
person.setName(model.getName()); personService.update(person);
personService.update(person);
flag = true; flag = true;
tipMsg = "成功"; tipMsg = "成功";
tipType = 0; tipType = 0;
} } catch (DataAccessException e) {
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>修改经手人ID为 : " + model.getPersonID() + "信息失败", e); Log.errorFileSync(">>>>>>>>>>>>>修改经手人ID为 : " + model.getPersonID() + "信息失败", e);
flag = false; flag = false;
tipMsg = "失败"; tipMsg = "失败";
tipType = 1; tipType = 1;
} } finally {
finally try {
{
try
{
toClient(flag.toString()); toClient(flag.toString());
} } catch (IOException e) {
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>修改经手人回写客户端结果异常", e); Log.errorFileSync(">>>>>>>>>>>>修改经手人回写客户端结果异常", e);
} }
} }
logService.create(new Logdetails(getUser(), "更新经手人", model.getClientIp(), logService.create(new Logdetails(getUser(), "更新经手人", model.getClientIp(),
new Timestamp(System.currentTimeMillis()) new Timestamp(System.currentTimeMillis())
, tipType, "更新经手人ID为 "+ model.getPersonID() + " " + tipMsg + "!", "更新经手人" + tipMsg)); , tipType, "更新经手人ID为 " + model.getPersonID() + " " + tipMsg + "!", "更新经手人" + tipMsg));
} }
/** /**
* 批量删除指定ID经手人 * 批量删除指定ID经手人
* @return *
*/ * @return
public String batchDelete() */
{ public String batchDelete() {
try try {
{ personService.batchDelete(model.getPersonIDs());
personService.batchDelete(model.getPersonIDs());
model.getShowModel().setMsgTip("成功"); model.getShowModel().setMsgTip("成功");
//记录操作日志使用 //记录操作日志使用
tipMsg = "成功"; tipMsg = "成功";
tipType = 0; tipType = 0;
} } catch (DataAccessException e) {
catch (DataAccessException e) Log.errorFileSync(">>>>>>>>>>>批量删除经手人ID为:" + model.getPersonIDs() + "信息异常", e);
{ tipMsg = "失败";
Log.errorFileSync(">>>>>>>>>>>批量删除经手人ID为:" + model.getPersonIDs() + "信息异常", e);
tipMsg = "失败";
tipType = 1; tipType = 1;
} }
logService.create(new Logdetails(getUser(), "批量删除经手人", model.getClientIp(), logService.create(new Logdetails(getUser(), "批量删除经手人", model.getClientIp(),
new Timestamp(System.currentTimeMillis()) new Timestamp(System.currentTimeMillis())
, tipType, "批量删除经手人ID为 "+ model.getPersonIDs() + " " + tipMsg + "!", "批量删除经手人" + tipMsg)); , tipType, "批量删除经手人ID为 " + model.getPersonIDs() + " " + tipMsg + "!", "批量删除经手人" + tipMsg));
return SUCCESS; return SUCCESS;
} }
/** /**
* 查找经手人信息 * 查找经手人信息
* @return *
*/ * @return
public void findBy() */
{ public void findBy() {
try try {
{ PageUtil<Person> pageUtil = new PageUtil<Person>();
PageUtil<Person> pageUtil = new PageUtil<Person>();
pageUtil.setPageSize(model.getPageSize()); pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo()); pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition()); pageUtil.setAdvSearch(getCondition());
personService.find(pageUtil); personService.find(pageUtil);
List<Person> dataList = pageUtil.getPageList(); List<Person> dataList = pageUtil.getPageList();
JSONObject outer = new JSONObject(); JSONObject outer = new JSONObject();
outer.put("total", pageUtil.getTotalCount()); outer.put("total", pageUtil.getTotalCount());
//存放数据json数组 //存放数据json数组
JSONArray dataArray = new JSONArray(); JSONArray dataArray = new JSONArray();
if(null != dataList) if (null != dataList) {
{ for (Person person : dataList) {
for(Person person:dataList)
{
JSONObject item = new JSONObject(); JSONObject item = new JSONObject();
item.put("Id", person.getId()); item.put("Id", person.getId());
item.put("Type", person.getType()); item.put("Type", person.getType());
...@@ -323,40 +286,35 @@ public class PersonAction extends BaseAction<PersonModel> ...@@ -323,40 +286,35 @@ public class PersonAction extends BaseAction<PersonModel>
outer.put("rows", dataArray); outer.put("rows", dataArray);
//回写查询结果 //回写查询结果
toClient(outer.toString()); toClient(outer.toString());
} } catch (DataAccessException e) {
catch (DataAccessException e) Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找经手人信息异常", e);
{ } catch (IOException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找经手人信息异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询经手人信息结果异常", e); Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询经手人信息结果异常", e);
} }
} }
/** /**
* 拼接搜索条件 * 拼接搜索条件
* @return *
*/ * @return
private Map<String,Object> getCondition() */
{ private Map<String, Object> getCondition() {
/** /**
* 拼接搜索条件 * 拼接搜索条件
*/ */
Map<String,Object> condition = new HashMap<String,Object>(); Map<String, Object> condition = new HashMap<String, Object>();
condition.put("Name_s_like", model.getName()); condition.put("Name_s_like", model.getName());
condition.put("Type_s_eq", model.getType()); condition.put("Type_s_eq", model.getType());
return condition; return condition;
} }
//=============以下spring注入以及Model驱动公共方法,与Action处理无关================== //=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
@Override @Override
public PersonModel getModel() public PersonModel getModel() {
{ return model;
return model; }
}
public void setPersonService(PersonIService personService) public void setPersonService(PersonIService personService) {
{
this.personService = personService; this.personService = personService;
} }
} }
package com.jsh.base; package com.jsh.base;
import java.io.IOException; import com.jsh.model.po.Basicuser;
import java.util.Map; import com.jsh.service.basic.LogIService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import org.apache.struts2.ServletActionContext;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;
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工具类 * struts2工具类
*
* @author jishenghua qq752718920 * @author jishenghua qq752718920
* struts2 base action 一些常用方法获取 * struts2 base action 一些常用方法获取
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public abstract class BaseAction<T> extends ActionSupport implements ModelDriven<T> public abstract class BaseAction<T> extends ActionSupport implements ModelDriven<T> {
{ public LogIService logService;
public LogIService logService;
/**
/** * 操作日志使用 是否成功表示
* 操作日志使用 是否成功表示 */
*/
public String tipMsg = "成功"; public String tipMsg = "成功";
/** /**
* 操作日志使用 是否成功表示 0 ==成功 1==失败 * 操作日志使用 是否成功表示 0 ==成功 1==失败
*/ */
public short tipType = 0; public short tipType = 0;
public void setLogService(LogIService logService) /**
{ * 获取session
this.logService = logService; *
} * @return
*/
/** public static Map<String, Object> getSession() {
* 获取session return ActionContext.getContext().getSession();
* @return }
*/
public static Map<String,Object> getSession() /**
{ * 获取request
return ActionContext.getContext().getSession(); *
} * @return
*/
/** public static HttpServletRequest getRequest() {
* 获取request return ServletActionContext.getRequest();
* @return }
*/
public static HttpServletRequest getRequest() /**
{ * 获取response
return ServletActionContext.getRequest(); *
} * @return response
/** */
* 获取response public static HttpServletResponse getResponse() {
* @return response return ServletActionContext.getResponse();
*/ }
public static HttpServletResponse getResponse()
{ public void setLogService(LogIService logService) {
return ServletActionContext.getResponse(); this.logService = logService;
} }
/** /**
* 添加错误信息 * 添加错误信息
*
* @param anErrorMessage * @param anErrorMessage
*/ */
public void addActionError(String anErrorMessage) public void addActionError(String anErrorMessage) {
{
super.addActionError(anErrorMessage); super.addActionError(anErrorMessage);
} }
/** /**
* 添加消息 * 添加消息
*
* @param aMessage * @param aMessage
*/ */
public void addActionMessage(String aMessage) public void addActionMessage(String aMessage) {
{
clearErrorsAndMessages(); clearErrorsAndMessages();
super.addActionMessage(aMessage); super.addActionMessage(aMessage);
} }
/** /**
* 添加字段错误 * 添加字段错误
*
* @param fieldName * @param fieldName
* @param errorMessage * @param errorMessage
*/ */
public void addFieldError(String fieldName, String errorMessage) public void addFieldError(String fieldName, String errorMessage) {
{
clearErrorsAndMessages(); clearErrorsAndMessages();
super.addFieldError(fieldName, errorMessage); super.addFieldError(fieldName, errorMessage);
} }
/** /**
* 登录用户信息 * 登录用户信息
*
* @return 登录用户对象 * @return 登录用户对象
*/ */
public Basicuser getUser() public Basicuser getUser() {
{ return (Basicuser) getSession().get("user");
return (Basicuser)getSession().get("user");
} }
/** /**
* 回写客户端数据 * 回写客户端数据
* @throws IOException *
* @throws IOException
*/ */
public void toClient(String jsonData) throws IOException public void toClient(String jsonData) throws IOException {
{
HttpServletResponse response = ServletActionContext.getResponse(); HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text/html;charset=utf-8"); response.setContentType("text/html;charset=utf-8");
response.getWriter().print(jsonData); response.getWriter().print(jsonData);
......
package com.jsh.base; package com.jsh.base;
import java.io.Serializable; import com.jsh.util.PageUtil;
import java.util.List; import com.jsh.util.SearchConditionUtil;
import java.util.Map;
import org.hibernate.Query; import org.hibernate.Query;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport; import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.jsh.util.PageUtil; import java.io.Serializable;
import com.jsh.util.SearchConditionUtil; import java.util.List;
import java.util.Map;
/** /**
* 基础dao * 基础dao
*
* @author ji_sheng_hua qq:752718920 * @author ji_sheng_hua qq:752718920
*/ */
public class BaseDAO<T> extends HibernateDaoSupport implements BaseIDAO<T> public class BaseDAO<T> extends HibernateDaoSupport implements BaseIDAO<T> {
{ protected Class<T> entityClass;
protected Class<T> entityClass;
public void setPoJoClass(Class<T> c) {
public void setPoJoClass(Class<T> c) this.entityClass = c;
{ }
this.entityClass = c;
} protected Class<T> getEntityClass() {
return this.entityClass;
protected Class<T> getEntityClass() }
{
return this.entityClass; @Override
} public Serializable create(T t) throws DataAccessException {
return this.getHibernateTemplate().save(t);
@Override }
public Serializable create(T t) throws DataAccessException
{ @Override
return this.getHibernateTemplate().save(t); public void delete(T t) throws DataAccessException {
} this.getHibernateTemplate().delete(t);
}
@Override
public void delete(T t) throws DataAccessException @Override
{ public T get(Long objID) throws DataAccessException {
this.getHibernateTemplate().delete(t); return (T) this.getHibernateTemplate().get(getEntityClass(), objID);
} }
@Override @Override
public T get(Long objID) throws DataAccessException public void update(T t) throws DataAccessException {
{ this.getHibernateTemplate().update(t);
return (T) this.getHibernateTemplate().get(getEntityClass(), objID); }
}
@Override
@Override public void batchDelete(String objIDs) throws DataAccessException {
public void update(T t) throws DataAccessException this.getHibernateTemplate().bulkUpdate("delete from " + getEntityClass().getName() + " where id in (" + objIDs + ")");
{ }
this.getHibernateTemplate().update(t);
} @SuppressWarnings("unchecked")
@Override
@Override public void find(PageUtil<T> pageUtil) throws DataAccessException {
public void batchDelete(String objIDs) throws DataAccessException Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession()
{ .createQuery(" from " + getEntityClass().getName() + " where 1=1 " +
this.getHibernateTemplate().bulkUpdate("delete from " + getEntityClass().getName() + " where id in ("+ objIDs + ")"); SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
} pageUtil.setTotalCount(query.list().size());
@SuppressWarnings("unchecked") // 分页查询
@Override int pageNo = pageUtil.getCurPage();
public void find(PageUtil<T> pageUtil) throws DataAccessException int pageSize = pageUtil.getPageSize();
{ if (0 != pageNo && 0 != pageSize) {
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession() query.setFirstResult((pageNo - 1) * pageSize);
.createQuery(" from " + getEntityClass().getName() + " where 1=1 "+ query.setMaxResults(pageSize);
SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); }
pageUtil.setTotalCount(query.list().size()); pageUtil.setPageList(query.list());
}
// 分页查询
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());
}
// @SuppressWarnings("unchecked") // @SuppressWarnings("unchecked")
// @Override // @Override
...@@ -92,49 +83,44 @@ public class BaseDAO<T> extends HibernateDaoSupport implements BaseIDAO<T> ...@@ -92,49 +83,44 @@ public class BaseDAO<T> extends HibernateDaoSupport implements BaseIDAO<T>
// return this.getHibernateTemplate().find(" from " + getEntityClass().getName() + " where 1=1 "+ hql); // return this.getHibernateTemplate().find(" from " + getEntityClass().getName() + " where 1=1 "+ hql);
// } // }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public List<T> find(Map<String, Object> conditon, int pageSize, int pageNo)throws DataAccessException public List<T> find(Map<String, Object> conditon, int pageSize, int pageNo) throws DataAccessException {
{ Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession()
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession() .createQuery(" from " + getEntityClass().getName() + " where 1=1 " + SearchConditionUtil.getCondition(conditon));
.createQuery(" from " + getEntityClass().getName() + " where 1=1 "+ SearchConditionUtil.getCondition(conditon)); query.setFirstResult((pageNo - 1) * pageSize);
query.setFirstResult((pageNo - 1) * pageSize); query.setMaxResults(pageSize);
query.setMaxResults(pageSize); return query.list();
return query.list(); }
}
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") @Override
@Override public List<T> find(String hql, int pageSize, int pageNo) throws DataAccessException {
public List<T> find(String hql, int pageSize, int pageNo)throws DataAccessException Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession()
{ .createQuery(" from " + getEntityClass().getName() + " where 1=1 " + hql);
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession() query.setFirstResult((pageNo - 1) * pageSize);
.createQuery(" from " + getEntityClass().getName() + " where 1=1 "+ hql); query.setMaxResults(pageSize);
query.setFirstResult((pageNo - 1) * pageSize); return query.list();
query.setMaxResults(pageSize); }
return query.list();
} @SuppressWarnings("unchecked")
@Override
@SuppressWarnings("unchecked") public Integer countSum(Map<String, Object> conditon) throws DataAccessException {
@Override List<T> dataList = this.getHibernateTemplate().getSessionFactory().getCurrentSession()
public Integer countSum(Map<String, Object> conditon)throws DataAccessException .createQuery(" from " + getEntityClass().getName() + " where 1=1 " + SearchConditionUtil.getCondition(conditon)).list();
{ return dataList == null ? 0 : dataList.size();
List<T> dataList = this.getHibernateTemplate().getSessionFactory().getCurrentSession() }
.createQuery(" from " + getEntityClass().getName() + " where 1=1 "+ SearchConditionUtil.getCondition(conditon)).list();
return dataList ==null?0:dataList.size(); @SuppressWarnings("unchecked")
} @Override
public Integer countSum(String hql) throws DataAccessException {
@SuppressWarnings("unchecked") List<T> dataList = this.getHibernateTemplate().getSessionFactory().getCurrentSession()
@Override .createQuery(" from " + getEntityClass().getName() + " where 1=1 " + hql).list();
public Integer countSum(String hql) throws DataAccessException return dataList == null ? 0 : dataList.size();
{ }
List<T> dataList = this.getHibernateTemplate().getSessionFactory().getCurrentSession()
.createQuery(" from " + getEntityClass().getName() + " where 1=1 "+ hql).list();
return dataList ==null?0:dataList.size();
}
@Override @Override
public void save(T t) throws DataAccessException public void save(T t) throws DataAccessException {
{
this.getHibernateTemplate().save(t); this.getHibernateTemplate().save(t);
} }
} }
package com.jsh.base; package com.jsh.base;
import com.jsh.util.PageUtil;
import org.springframework.dao.DataAccessException;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.dao.DataAccessException;
import com.jsh.util.PageUtil;
/** /**
* 常用增删改查操作 * 常用增删改查操作
* @author ji-sheng-hua qq752718920 *
* @param <T> * @param <T>
* @author ji-sheng-hua qq752718920
*/ */
public interface BaseIDAO<T> public interface BaseIDAO<T> {
{
/**
/** * 设置操作类对象
* 设置操作类对象 *
* @param paramClass * @param paramClass
*/ */
void setPoJoClass(Class<T> paramClass); void setPoJoClass(Class<T> paramClass);
/** /**
* 增加
* @param t 对象
* @throws DataAccessException
*/
Serializable create(T t)throws DataAccessException;
/**
* 增加 * 增加
*
* @param t 对象 * @param t 对象
* @throws DataAccessException * @throws DataAccessException
*/ */
void save(T t)throws DataAccessException; Serializable create(T t) throws DataAccessException;
/** /**
* 删除 * 增加
* @param t 对象 *
* @throws DataAccessException * @param t 对象
*/ * @throws DataAccessException
void delete(T t)throws DataAccessException; */
void save(T t) throws DataAccessException;
/**
* 获取 /**
* @param objID ID * 删除
* @return 对象 *
* @throws DataAccessException * @param t 对象
*/ * @throws DataAccessException
T get(Long objID)throws DataAccessException; */
void delete(T t) throws DataAccessException;
/**
* 修改信息 /**
* @param t 要修改的对象 * 获取
* @throws DataAccessException *
*/ * @param objID ID
void update(T t)throws DataAccessException; * @return 对象
* @throws DataAccessException
/** */
* 批量删除信息 T get(Long objID) throws DataAccessException;
* @param 以逗号分割的ID
* @throws DataAccessException /**
*/ * 修改信息
void batchDelete(String objIDs)throws DataAccessException; *
* @param t 要修改的对象
/** * @throws DataAccessException
* 查找列表 */
* @param pageUtil 分页工具类 void update(T t) throws DataAccessException;
* @throws DataAccessException
*/ /**
void find(PageUtil<T> pageUtil)throws DataAccessException; * 批量删除信息
*
/** * @param 以逗号分割的ID
* 根据条件查询列表--没有分页信息 * @throws DataAccessException
* @param conditon 查询条件 */
* @return 查询列表数据 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; // List<T> find(Map<String,Object> conditon)throws DataAccessException;
/** /**
* 根据hql查询 --没有分页信息 * 根据hql查询 --没有分页信息
* @param hql hibernate查询 * @param hql hibernate查询
* @return 查询列表数据 * @return 查询列表数据
*/ */
// List<T> find(String hql)throws DataAccessException; // List<T> find(String hql)throws DataAccessException;
/** /**
* 根据搜索条件查询--分页 * 根据搜索条件查询--分页
* @param conditon 查询条件 *
* @param pageSize 每页个数 * @param conditon 查询条件
* @param pageNo 页码 * @param pageSize 每页个数
* @return 查询列表数据 * @param pageNo 页码
* @throws DataAccessException * @return 查询列表数据
*/ * @throws DataAccessException
List<T> find(Map<String,Object> conditon,int pageSize,int pageNo)throws DataAccessException; */
List<T> find(Map<String, Object> conditon, int pageSize, int pageNo) throws DataAccessException;
/**
* 根据hql查询--分页 /**
* @param hql hibernate查询语句 * 根据hql查询--分页
* @param pageSize 每页个数 *
* @param pageNo 页码 * @param hql hibernate查询语句
* @return 查询列表数据 * @param pageSize 每页个数
* @throws DataAccessException * @param pageNo 页码
*/ * @return 查询列表数据
List<T> find(String hql,int pageSize,int pageNo)throws DataAccessException; * @throws DataAccessException
*/
/** List<T> find(String hql, int pageSize, int pageNo) throws DataAccessException;
* 查找符合条件的总数
* @param conditon /**
* @return * 查找符合条件的总数
* @throws DataAccessException *
*/ * @param conditon
Integer countSum(Map<String,Object> conditon)throws DataAccessException; * @return
* @throws DataAccessException
/** */
* 查找符合条件的总数 Integer countSum(Map<String, Object> conditon) throws DataAccessException;
* @param hql
* @return /**
* @throws DataAccessException * 查找符合条件的总数
*/ *
Integer countSum(String hql)throws DataAccessException; * @param hql
* @return
* @throws DataAccessException
*/
Integer countSum(String hql) throws DataAccessException;
} }
package com.jsh.base; package com.jsh.base;
import java.io.Serializable; import com.jsh.util.PageUtil;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import com.jsh.util.PageUtil; import java.io.Serializable;
/** /**
* 服务层底层接口 * 服务层底层接口
* @author ji-sheng-hua qq752718920 *
* @param <T> * @param <T>
* @author ji-sheng-hua qq752718920
*/ */
public interface BaseIService<T> public interface BaseIService<T> {
{ /**
/** * 增加
* 增加 *
* @param t 对象 * @param t 对象
* @throws DataAccessException * @throws DataAccessException
*/ */
Serializable create(T t)throws DataAccessException; Serializable create(T t) throws DataAccessException;
/** /**
* 增加 * 增加
*
* @param t 对象
* @throws DataAccessException
*/
void save(T t) throws DataAccessException;
/**
* 删除
*
* @param t 对象 * @param t 对象
* @throws DataAccessException * @throws DataAccessException
*/ */
void save(T t)throws DataAccessException; void delete(T t) throws DataAccessException;
/** /**
* 删除 * 删除
* @param t 对象 *
* @throws DataAccessException * @param id 对象ID
*/ * @throws DataAccessException
void delete(T t)throws DataAccessException; */
void delete(Long id) throws DataAccessException;
/**
* 删除 /**
* @param id 对象ID * 获取
* @throws DataAccessException *
*/ * @param objID ID
void delete(Long id)throws DataAccessException; * @return 对象
* @throws DataAccessException
/** */
* 获取 T get(Long objID) 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 t 要修改的对象
* @throws DataAccessException /**
*/ * 批量删除信息
void update(T t)throws DataAccessException; *
* @param 以逗号分割的ID
/** * @throws DataAccessException
* 批量删除信息 */
* @param 以逗号分割的ID void batchDelete(String objIDs) throws DataAccessException;
* @throws DataAccessException
*/ /**
void batchDelete(String objIDs)throws DataAccessException; * 查找列表
*
/** * @param pageUtil 分页工具类
* 查找列表 * @throws DataAccessException
* @param pageUtil 分页工具类 */
* @throws DataAccessException void find(PageUtil<T> pageUtil) throws DataAccessException;
*/
void find(PageUtil<T> pageUtil) throws DataAccessException; /**
* 检查名称是否存在,页面唯一性效验使用
/** *
* 检查名称是否存在,页面唯一性效验使用 * @param filedName 效验的字段名称
* @param filedName 效验的字段名称 * @param filedVale 校验值
* @param filedVale 校验值 * @param idFiled ID字段名称
* @param idFiled ID字段名称 * @param objectID 修改时对象ID
* @param objectID 修改时对象ID * @return true==存在 false==不存在
* @return true==存在 false==不存在 * @throws DataAccessException
* @throws DataAccessException */
*/ Boolean checkIsNameExist(String filedName, String filedVale, String idFiled, Long objectID) throws DataAccessException;
Boolean checkIsNameExist(String filedName,String filedVale,String idFiled,Long objectID) throws DataAccessException;
/**
/** * 检查UserBusiness是否存在,页面唯一性效验使用
* 检查UserBusiness是否存在,页面唯一性效验使用 *
* @param TypeName 类型名称 * @param TypeName 类型名称
* @param TypeVale 类型值 * @param TypeVale 类型值
* @param KeyIdName 关键id * @param KeyIdName 关键id
* @param KeyIdValue 关键值 * @param KeyIdValue 关键值
* @param UBName 关系名称 * @param UBName 关系名称
* @param UBValue 关系值 * @param UBValue 关系值
* @return true==存在 false==不存在 * @return true==存在 false==不存在
* @throws DataAccessException * @throws DataAccessException
*/ */
Boolean checkIsUserBusinessExist(String TypeName,String TypeVale,String KeyIdName,String KeyIdValue,String UBName,String UBValue) throws DataAccessException; Boolean checkIsUserBusinessExist(String TypeName, String TypeVale, String KeyIdName, String KeyIdValue, String UBName, String UBValue) throws DataAccessException;
/** /**
* 检查UserBusiness是否存在,页面唯一性效验使用 * 检查UserBusiness是否存在,页面唯一性效验使用
* @param TypeName 类型名称 *
* @param TypeVale 类型 * @param TypeName 类型名称
* @param KeyIdName 关键id * @param TypeVale 类型值
* @param KeyIdValue 关键 * @param KeyIdName 关键id
* @return true==存在 false==不存在 * @param KeyIdValue 关键值
* @throws DataAccessException * @return true==存在 false==不存在
*/ * @throws DataAccessException
Boolean checkIsValueExist(String TypeName, String TypeVale, String KeyIdName, String KeyIdValue) throws DataAccessException; */
Boolean checkIsValueExist(String TypeName, String TypeVale, String KeyIdName, String KeyIdValue) throws DataAccessException;
} }
package com.jsh.base; package com.jsh.base;
import com.jsh.util.PageUtil;
import org.springframework.dao.DataAccessException;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.dao.DataAccessException;
import com.jsh.util.JshException;
import com.jsh.model.po.Basicuser;
import com.jsh.util.PageUtil;
/** /**
* 底层服务层 * 底层服务层
* @author ji-sheng-hua qq752718920 *
* @param <T> * @param <T>
* @author ji-sheng-hua qq752718920
*/ */
public abstract class BaseService<T> implements BaseIService<T> public abstract class BaseService<T> implements BaseIService<T> {
{ protected Class<T> entityClass;
/** /**
* Dao对象 * Dao对象
*/ */
private BaseIDAO<T> baseDao; private BaseIDAO<T> baseDao;
protected Class<T> entityClass; protected BaseIDAO<T> getBaseDao() {
return this.baseDao;
public void setBaseDao(BaseIDAO<T> baseDao) }
{
this.baseDao = baseDao; public void setBaseDao(BaseIDAO<T> baseDao) {
setPoJoClass(getEntityClass()); this.baseDao = baseDao;
} setPoJoClass(getEntityClass());
}
protected BaseIDAO<T> getBaseDao()
{ private void setPoJoClass(Class<T> c) {
return this.baseDao; this.baseDao.setPoJoClass(c);
} }
private void setPoJoClass(Class<T> c) protected abstract Class<T> getEntityClass();
{
this.baseDao.setPoJoClass(c); @Override
} public Serializable create(T t) throws DataAccessException {
return baseDao.create(t);
protected abstract Class<T> getEntityClass(); }
@Override @Override
public Serializable create(T t) throws DataAccessException public void save(T t) throws DataAccessException {
{
return baseDao.create(t);
}
@Override
public void save(T t) throws DataAccessException
{
baseDao.save(t); baseDao.save(t);
} }
@Override @Override
public void delete(T t) throws DataAccessException public void delete(T t) throws DataAccessException {
{ baseDao.delete(t);
baseDao.delete(t); }
}
@Override
@Override public void delete(Long id) throws DataAccessException {
public void delete(Long id) throws DataAccessException baseDao.batchDelete(id.toString());
{ }
baseDao.batchDelete(id.toString());
} @Override
public T get(Long objID) throws DataAccessException {
@Override return baseDao.get(objID);
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 update(T t) throws DataAccessException
{ @Override
baseDao.update(t); public void batchDelete(String objIDs) throws DataAccessException {
} baseDao.batchDelete(objIDs);
}
@Override
public void batchDelete(String objIDs) throws DataAccessException @Override
{ public void find(PageUtil<T> pageUtil) throws DataAccessException {
baseDao.batchDelete(objIDs); baseDao.find(pageUtil);
} }
@Override @Override
public void find(PageUtil<T> pageUtil) throws DataAccessException public Boolean checkIsNameExist(String filedName, String filedVale, String idFiled, Long objectID) throws DataAccessException {
{ PageUtil<T> pageUtil = new PageUtil<T>();
baseDao.find(pageUtil); Map<String, Object> condition = new HashMap<String, Object>();
}
@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(filedName + "_s_eq", filedVale);
condition.put(idFiled + "_n_neq", objectID); condition.put(idFiled + "_n_neq", objectID);
pageUtil.setAdvSearch(condition); pageUtil.setAdvSearch(condition);
baseDao.find(pageUtil); baseDao.find(pageUtil);
List<T> dataList = pageUtil.getPageList(); List<T> dataList = pageUtil.getPageList();
if(null != dataList && dataList.size() > 0) if (null != dataList && dataList.size() > 0)
return true; return true;
return false; return false;
} }
@Override @Override
public Boolean checkIsUserBusinessExist(String TypeName,String TypeVale,String KeyIdName,String KeyIdValue,String UBName,String UBValue) throws DataAccessException public Boolean checkIsUserBusinessExist(String TypeName, String TypeVale, String KeyIdName, String KeyIdValue, String UBName, String UBValue) throws DataAccessException {
{ PageUtil<T> pageUtil = new PageUtil<T>();
PageUtil<T> pageUtil = new PageUtil<T>(); Map<String, Object> condition = new HashMap<String, Object>();
Map<String,Object> condition = new HashMap<String,Object>();
condition.put(TypeName + "_s_eq", TypeVale); condition.put(TypeName + "_s_eq", TypeVale);
condition.put(KeyIdName + "_s_eq", KeyIdValue); condition.put(KeyIdName + "_s_eq", KeyIdValue);
condition.put(UBName + "_s_like", UBValue); condition.put(UBName + "_s_like", UBValue);
pageUtil.setAdvSearch(condition); pageUtil.setAdvSearch(condition);
baseDao.find(pageUtil); baseDao.find(pageUtil);
List<T> dataList = pageUtil.getPageList(); List<T> dataList = pageUtil.getPageList();
if(null != dataList && dataList.size() > 0) if (null != dataList && dataList.size() > 0)
return true; return true;
return false; return false;
} }
@Override @Override
public Boolean checkIsValueExist(String TypeName, String TypeVale, String KeyIdName, String KeyIdValue) throws DataAccessException public Boolean checkIsValueExist(String TypeName, String TypeVale, String KeyIdName, String KeyIdValue) throws DataAccessException {
{ PageUtil<T> pageUtil = new PageUtil<T>();
PageUtil<T> pageUtil = new PageUtil<T>(); Map<String, Object> condition = new HashMap<String, Object>();
Map<String,Object> condition = new HashMap<String,Object>();
condition.put(TypeName + "_s_eq", TypeVale); condition.put(TypeName + "_s_eq", TypeVale);
condition.put(KeyIdName + "_s_eq", KeyIdValue); condition.put(KeyIdName + "_s_eq", KeyIdValue);
pageUtil.setAdvSearch(condition); pageUtil.setAdvSearch(condition);
baseDao.find(pageUtil); baseDao.find(pageUtil);
List<T> dataList = pageUtil.getPageList(); List<T> dataList = pageUtil.getPageList();
if(null != dataList && dataList.size() > 0) if (null != dataList && dataList.size() > 0)
return true; return true;
return false; return false;
} }
} }
...@@ -4,171 +4,162 @@ import org.apache.log4j.Logger; ...@@ -4,171 +4,162 @@ import org.apache.log4j.Logger;
/** /**
* 封装log4j日志信息,打印日志信息类 * 封装log4j日志信息,打印日志信息类
*
* @author ji/sheng/hua qq_7527.18920 * @author ji/sheng/hua qq_7527.18920
* @since 2014-01-22 * @since 2014-01-22
*/ */
public class Log public class Log {
{ /**
/** * Info级别日志前缀
* 根据异常信息获取调用类的信息 */
*/ public static final String LOG_INFO_PREFIX = "==========";
private static final Exception ex = new Exception(); /**
* error级别日志前缀
/** */
* 获取Log4j实例 public static final String LOG_ERROR_PREFIX = ">>>>>>>>>>";
*/ /**
private static final Logger log = Logger.getLogger("jsh"); * debug级别日志前缀
*/
/** public static final String LOG_DEBUG_PREFIX = "-----------";
* Info级别日志前缀 /**
*/ * fatal级别日志前缀
public static final String LOG_INFO_PREFIX = "=========="; */
public static final String LOG_FATAL_PREFIX = "$$$$$$$$$$";
/** /**
* error级别日志前缀 * warn级别日志前缀
*/ */
public static final String LOG_ERROR_PREFIX = ">>>>>>>>>>"; public static final String LOG_WARN_PREFIX = "##########";
/**
/** * 根据异常信息获取调用类的信息
* debug级别日志前缀 */
*/ private static final Exception ex = new Exception();
public static final String LOG_DEBUG_PREFIX = "-----------"; /**
* 获取Log4j实例
/** */
* fatal级别日志前缀 private static final Logger log = Logger.getLogger("jsh");
*/
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异常信息 * 打印deug日期信息
* @param msg 日志信息 *
* @param e 异常堆栈 * @param msg 日志信息
*/ */
public static void debugFileSync(Object msg, Throwable e) public static void debugFileSync(Object msg) {
{ log.debug(getLogDetail(msg));
log.debug(getLogDetail(msg), e); }
}
/** /**
* 打印info日志信息 * 打印debug异常信息
* @param msg 日志信息 *
*/ * @param msg 日志信息
public static void infoFileSync(Object msg) * @param e 异常堆栈
{ */
log.info(getLogDetail(msg)); public static void debugFileSync(Object msg, Throwable e) {
} log.debug(getLogDetail(msg), e);
}
/** /**
* 打印 info日志带异常信息 * 打印info日志信息
* @param msg 日志信息 *
* @param e 异常堆栈 * @param msg 日志信息
*/ */
public static void infoFileSync(Object msg, Throwable e) public static void infoFileSync(Object msg) {
{ log.info(getLogDetail(msg));
log.info(getLogDetail(msg), e); }
}
/** /**
* 打印warn日期信息 * 打印 info日志带异常信息
* @param msg 日志信息 *
*/ * @param msg 日志信息
public static void warnFileSync(Object msg) * @param e 异常堆栈
{ */
log.warn(getLogDetail(msg)); public static void infoFileSync(Object msg, Throwable e) {
} log.info(getLogDetail(msg), e);
}
/** /**
* 打印warn日志信息带异常 * 打印warn日期信息
* @param msg日志信息 *
* @param e 异常堆栈 * @param msg 日志信息
*/ */
public static void warnFileSync(Object msg, Throwable e) public static void warnFileSync(Object msg) {
{ log.warn(getLogDetail(msg));
log.warn(getLogDetail(msg), e); }
}
/** /**
* 打印error日志信息 * 打印warn日志信息带异常
* @param msg 日志信息 *
*/ * @param msg日志信息
public static void errorFileSync(Object msg) * @param e 异常堆栈
{ */
log.error(getLogDetail(msg)); public static void warnFileSync(Object msg, Throwable e) {
} log.warn(getLogDetail(msg), e);
}
/** /**
* 打印error日志信息带异常 * 打印error日志信息
* @param msg 日志信息 *
* @param e 异常堆栈 * @param msg 日志信息
*/ */
public static void errorFileSync(Object msg, Throwable e) public static void errorFileSync(Object msg) {
{ log.error(getLogDetail(msg));
log.error(getLogDetail(msg), e); }
}
/** /**
* 打印fatal日志信息 * 打印error日志信息带异常
* @param msg 日志信息 *
*/ * @param msg 日志信息
public static void fatalFileSync(Object msg) * @param e 异常堆栈
{ */
log.fatal(getLogDetail(msg)); public static void errorFileSync(Object msg, Throwable e) {
} log.error(getLogDetail(msg), e);
}
/** /**
* 打印fatal日志信息带异常 * 打印fatal日志信息
* @param msg 日志信息 *
* @param e 异常堆栈 * @param msg 日志信息
*/ */
public static void fatalFileSync(Object msg, Throwable e) public static void fatalFileSync(Object msg) {
{ log.fatal(getLogDetail(msg));
log.fatal(getLogDetail(msg), e); }
}
/**
/** * 打印fatal日志信息带异常
* 拼装日志详细信息 *
* @param message 要打印的日志信息 * @param msg 日志信息
* @return 封装后的日志详细信息 * @param e 异常堆栈
*/ */
private static synchronized String getLogDetail(Object message) public static void fatalFileSync(Object msg, Throwable e) {
{ log.fatal(getLogDetail(msg), e);
String msg = ""; }
if (null != message)
msg = message.toString(); /**
StringBuffer bf = new StringBuffer(); * 拼装日志详细信息
try *
{ * @param message 要打印的日志信息
ex.fillInStackTrace(); * @return 封装后的日志详细信息
throw ex; */
} private static synchronized String getLogDetail(Object message) {
catch (Exception ex) String msg = "";
{ if (null != message)
StackTraceElement[] trace = ex.getStackTrace(); msg = message.toString();
//获取异常堆栈中的调用类信息 StringBuffer bf = new StringBuffer();
final int pos = 2; try {
bf.append(msg); ex.fillInStackTrace();
bf.append(" [class:"); throw ex;
bf.append(trace[pos].getClassName()); } catch (Exception ex) {
bf.append(" method:"); StackTraceElement[] trace = ex.getStackTrace();
bf.append(trace[pos].getMethodName()); //获取异常堆栈中的调用类信息
bf.append(" line:"); final int pos = 2;
bf.append(trace[pos].getLineNumber()); bf.append(msg);
bf.append("]"); bf.append(" [class:");
} bf.append(trace[pos].getClassName());
return bf.toString(); bf.append(" method:");
} bf.append(trace[pos].getMethodName());
bf.append(" line:");
bf.append(trace[pos].getLineNumber());
bf.append("]");
}
return bf.toString();
}
} }
...@@ -3,15 +3,14 @@ package com.jsh.dao.asset; ...@@ -3,15 +3,14 @@ package com.jsh.dao.asset;
import com.jsh.base.BaseDAO; import com.jsh.base.BaseDAO;
import com.jsh.model.po.Asset; import com.jsh.model.po.Asset;
public class AssetDAO extends BaseDAO<Asset> implements AssetIDAO public class AssetDAO extends BaseDAO<Asset> implements AssetIDAO {
{ /**
/**
* 设置dao映射基类 * 设置dao映射基类
*
* @return * @return
*/ */
@Override @Override
public Class<Asset> getEntityClass() public Class<Asset> getEntityClass() {
{
return Asset.class; return Asset.class;
} }
} }
...@@ -3,7 +3,6 @@ package com.jsh.dao.asset; ...@@ -3,7 +3,6 @@ package com.jsh.dao.asset;
import com.jsh.base.BaseIDAO; import com.jsh.base.BaseIDAO;
import com.jsh.model.po.Asset; import com.jsh.model.po.Asset;
public interface AssetIDAO extends BaseIDAO<Asset> public interface AssetIDAO extends BaseIDAO<Asset> {
{
} }
package com.jsh.dao.asset; package com.jsh.dao.asset;
import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.jsh.util.JshException;
import com.jsh.model.po.Asset; import com.jsh.model.po.Asset;
import com.jsh.util.JshException;
import com.jsh.util.PageUtil; import com.jsh.util.PageUtil;
import com.jsh.util.SearchConditionUtil; import com.jsh.util.SearchConditionUtil;
import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
public class ReportDAO extends HibernateDaoSupport implements ReportIDAO public class ReportDAO extends HibernateDaoSupport implements ReportIDAO {
{
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public void find(PageUtil<Asset> pageUtil,String reportType,String reportName) throws JshException 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()));
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.setTotalCount(query.list().size());
pageUtil.setPageList(query.list()); pageUtil.setPageList(query.list());
} }
......
package com.jsh.dao.asset; package com.jsh.dao.asset;
import com.jsh.util.JshException;
import com.jsh.model.po.Asset; import com.jsh.model.po.Asset;
import com.jsh.util.JshException;
import com.jsh.util.PageUtil; import com.jsh.util.PageUtil;
public interface ReportIDAO public interface ReportIDAO {
{
/** /**
* 查找资产列表 * 查找资产列表
* @param pageUtil 分页工具类 *
* @param pageUtil 分页工具类
* @param reportType 报表统计字段 * @param reportType 报表统计字段
* @throws JshException * @throws JshException
*/ */
void find(PageUtil<Asset> pageUtil,String reportType,String reportName) throws JshException; void find(PageUtil<Asset> pageUtil, String reportType, String reportName) throws JshException;
} }
...@@ -7,15 +7,14 @@ import com.jsh.util.PageUtil; ...@@ -7,15 +7,14 @@ import com.jsh.util.PageUtil;
import com.jsh.util.SearchConditionUtil; import com.jsh.util.SearchConditionUtil;
import org.hibernate.Query; import org.hibernate.Query;
public class AccountDAO extends BaseDAO<Account> implements AccountIDAO public class AccountDAO extends BaseDAO<Account> implements AccountIDAO {
{
/** /**
* 设置dao映射基类 * 设置dao映射基类
*
* @return * @return
*/ */
@Override @Override
public Class<Account> getEntityClass() public Class<Account> getEntityClass() {
{
return Account.class; return Account.class;
} }
...@@ -25,15 +24,15 @@ public class AccountDAO extends BaseDAO<Account> implements AccountIDAO ...@@ -25,15 +24,15 @@ public class AccountDAO extends BaseDAO<Account> implements AccountIDAO
//主表出入库涉及的账户 //主表出入库涉及的账户
queryString.append("select dh.Number,concat(dh.SubType,dh.Type) as newType,s.supplier,dh.ChangeAmount,date_format(dh.OperTime,'%Y-%m-%d %H:%i:%S') as oTime,'' as AList,'' as AMList " + queryString.append("select dh.Number,concat(dh.SubType,dh.Type) as newType,s.supplier,dh.ChangeAmount,date_format(dh.OperTime,'%Y-%m-%d %H:%i:%S') as oTime,'' as AList,'' as AMList " +
" from jsh_depothead dh inner join jsh_supplier s on dh.OrganId = s.id where 1=1 "); " from jsh_depothead dh inner join jsh_supplier s on dh.OrganId = s.id where 1=1 ");
if(accountId!=null && !accountId.equals("")) { if (accountId != null && !accountId.equals("")) {
queryString.append(" and dh.AccountId='"+ accountId +"' "); queryString.append(" and dh.AccountId='" + accountId + "' ");
} }
//主表收入和支出涉及的账户 //主表收入和支出涉及的账户
queryString.append("UNION ALL " + queryString.append("UNION ALL " +
"select ah.BillNo,ah.Type as newType,s.supplier,ah.ChangeAmount,date_format(ah.BillTime,'%Y-%m-%d %H:%i:%S') as oTime,'' as AList,'' as AMList " + "select ah.BillNo,ah.Type as newType,s.supplier,ah.ChangeAmount,date_format(ah.BillTime,'%Y-%m-%d %H:%i:%S') as oTime,'' as AList,'' as AMList " +
" from jsh_accounthead ah inner join jsh_supplier s on ah.OrganId=s.id where 1=1 "); " from jsh_accounthead ah inner join jsh_supplier s on ah.OrganId=s.id where 1=1 ");
if(accountId!=null && !accountId.equals("")) { if (accountId != null && !accountId.equals("")) {
queryString.append(" and ah.AccountId='"+ accountId +"' "); queryString.append(" and ah.AccountId='" + accountId + "' ");
} }
//明细中涉及的账户(收款,付款,收预付款) //明细中涉及的账户(收款,付款,收预付款)
queryString.append("UNION ALL " + queryString.append("UNION ALL " +
...@@ -41,31 +40,31 @@ public class AccountDAO extends BaseDAO<Account> implements AccountIDAO ...@@ -41,31 +40,31 @@ public class AccountDAO extends BaseDAO<Account> implements AccountIDAO
" from jsh_accounthead ah inner join jsh_supplier s on ah.OrganId=s.id " + " from jsh_accounthead ah inner join jsh_supplier s on ah.OrganId=s.id " +
" inner join jsh_accountitem ai on ai.HeaderId=ah.Id " + " inner join jsh_accountitem ai on ai.HeaderId=ah.Id " +
" where ah.Type in ('收款','付款','收预付款') "); " where ah.Type in ('收款','付款','收预付款') ");
if(accountId!=null && !accountId.equals("")) { if (accountId != null && !accountId.equals("")) {
queryString.append(" and ai.AccountId='"+ accountId +"' "); queryString.append(" and ai.AccountId='" + accountId + "' ");
} }
//主表中转出的账户 //主表中转出的账户
queryString.append("UNION ALL " + queryString.append("UNION ALL " +
"select ah.BillNo,ah.Type as newType, '' as sName,ah.ChangeAmount,date_format(ah.BillTime,'%Y-%m-%d %H:%i:%S') as oTime,'' as AList,'' as AMList " + "select ah.BillNo,ah.Type as newType, '' as sName,ah.ChangeAmount,date_format(ah.BillTime,'%Y-%m-%d %H:%i:%S') as oTime,'' as AList,'' as AMList " +
" from jsh_accounthead ah inner join jsh_accountitem ai on ai.HeaderId=ah.Id " + " from jsh_accounthead ah inner join jsh_accountitem ai on ai.HeaderId=ah.Id " +
" where ah.Type='转账' "); " where ah.Type='转账' ");
if(accountId!=null && !accountId.equals("")) { if (accountId != null && !accountId.equals("")) {
queryString.append(" and ah.AccountId='"+ accountId +"' "); queryString.append(" and ah.AccountId='" + accountId + "' ");
} }
//明细中被转入的账户 //明细中被转入的账户
queryString.append("UNION ALL " + queryString.append("UNION ALL " +
"select ah.BillNo,ah.Type as newType, '' as sName,ai.EachAmount,date_format(ah.BillTime,'%Y-%m-%d %H:%i:%S') as oTime,'' as AList,'' as AMList " + "select ah.BillNo,ah.Type as newType, '' as sName,ai.EachAmount,date_format(ah.BillTime,'%Y-%m-%d %H:%i:%S') as oTime,'' as AList,'' as AMList " +
" from jsh_accounthead ah inner join jsh_accountitem ai on ai.HeaderId=ah.Id " + " from jsh_accounthead ah inner join jsh_accountitem ai on ai.HeaderId=ah.Id " +
" where ah.Type='转账' "); " where ah.Type='转账' ");
if(accountId!=null && !accountId.equals("")) { if (accountId != null && !accountId.equals("")) {
queryString.append(" and ai.AccountId='"+ accountId +"' "); queryString.append(" and ai.AccountId='" + accountId + "' ");
} }
//多账户的情况 //多账户的情况
queryString.append("UNION ALL " + queryString.append("UNION ALL " +
"select dh.Number,concat(dh.SubType,dh.Type) as newType,s.supplier,dh.ChangeAmount,date_format(dh.OperTime,'%Y-%m-%d %H:%i:%S') as oTime,dh.AccountIdList,dh.AccountMoneyList" + "select dh.Number,concat(dh.SubType,dh.Type) as newType,s.supplier,dh.ChangeAmount,date_format(dh.OperTime,'%Y-%m-%d %H:%i:%S') as oTime,dh.AccountIdList,dh.AccountMoneyList" +
" from jsh_depothead dh inner join jsh_supplier s on dh.OrganId = s.id where 1=1 "); " from jsh_depothead dh inner join jsh_supplier s on dh.OrganId = s.id where 1=1 ");
if(accountId!=null && !accountId.equals("")) { if (accountId != null && !accountId.equals("")) {
queryString.append(" and dh.AccountIdList like '%\""+ accountId +"\"%' "); queryString.append(" and dh.AccountIdList like '%\"" + accountId + "\"%' ");
} }
queryString.append(" ORDER BY oTime desc"); queryString.append(" ORDER BY oTime desc");
Query query; Query query;
......
...@@ -3,15 +3,14 @@ package com.jsh.dao.basic; ...@@ -3,15 +3,14 @@ package com.jsh.dao.basic;
import com.jsh.base.BaseDAO; import com.jsh.base.BaseDAO;
import com.jsh.model.po.App; import com.jsh.model.po.App;
public class AppDAO extends BaseDAO<App> implements AppIDAO public class AppDAO extends BaseDAO<App> implements AppIDAO {
{ /**
/**
* 设置dao映射基类 * 设置dao映射基类
*
* @return * @return
*/ */
@Override @Override
public Class<App> getEntityClass() public Class<App> getEntityClass() {
{
return App.class; return App.class;
} }
} }
...@@ -3,7 +3,6 @@ package com.jsh.dao.basic; ...@@ -3,7 +3,6 @@ package com.jsh.dao.basic;
import com.jsh.base.BaseIDAO; import com.jsh.base.BaseIDAO;
import com.jsh.model.po.App; import com.jsh.model.po.App;
public interface AppIDAO extends BaseIDAO<App> public interface AppIDAO extends BaseIDAO<App> {
{
} }
...@@ -3,15 +3,14 @@ package com.jsh.dao.basic; ...@@ -3,15 +3,14 @@ package com.jsh.dao.basic;
import com.jsh.base.BaseDAO; import com.jsh.base.BaseDAO;
import com.jsh.model.po.Assetname; import com.jsh.model.po.Assetname;
public class AssetNameDAO extends BaseDAO<Assetname> implements AssetNameIDAO public class AssetNameDAO extends BaseDAO<Assetname> implements AssetNameIDAO {
{ /**
/**
* 设置dao映射基类 * 设置dao映射基类
*
* @return * @return
*/ */
@Override @Override
public Class<Assetname> getEntityClass() public Class<Assetname> getEntityClass() {
{
return Assetname.class; return Assetname.class;
} }
} }
...@@ -3,7 +3,6 @@ package com.jsh.dao.basic; ...@@ -3,7 +3,6 @@ package com.jsh.dao.basic;
import com.jsh.base.BaseIDAO; import com.jsh.base.BaseIDAO;
import com.jsh.model.po.Assetname; import com.jsh.model.po.Assetname;
public interface AssetNameIDAO extends BaseIDAO<Assetname> public interface AssetNameIDAO extends BaseIDAO<Assetname> {
{
} }
...@@ -3,15 +3,14 @@ package com.jsh.dao.basic; ...@@ -3,15 +3,14 @@ package com.jsh.dao.basic;
import com.jsh.base.BaseDAO; import com.jsh.base.BaseDAO;
import com.jsh.model.po.Category; import com.jsh.model.po.Category;
public class CategoryDAO extends BaseDAO<Category> implements CategoryIDAO public class CategoryDAO extends BaseDAO<Category> implements CategoryIDAO {
{ /**
/**
* 设置dao映射基类 * 设置dao映射基类
*
* @return * @return
*/ */
@Override @Override
public Class<Category> getEntityClass() public Class<Category> getEntityClass() {
{
return Category.class; return Category.class;
} }
} }
...@@ -3,7 +3,6 @@ package com.jsh.dao.basic; ...@@ -3,7 +3,6 @@ package com.jsh.dao.basic;
import com.jsh.base.BaseIDAO; import com.jsh.base.BaseIDAO;
import com.jsh.model.po.Category; import com.jsh.model.po.Category;
public interface CategoryIDAO extends BaseIDAO<Category> public interface CategoryIDAO extends BaseIDAO<Category> {
{
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment