Commit 86df29f6 authored by 季圣华's avatar 季圣华
Browse files

no commit message

parent b8a2b074
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.MaterialCategory;
import com.jsh.model.po.Logdetails;
import com.jsh.model.vo.materials.MaterialCategoryModel;
import com.jsh.service.materials.MaterialCategoryIService;
import com.jsh.util.common.PageUtil;
@SuppressWarnings("serial")
public class MaterialCategoryAction extends BaseAction<MaterialCategoryModel>
{
private MaterialCategoryIService materialCategoryService;
private MaterialCategoryModel model = new MaterialCategoryModel();
@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("ParentId_n_eq", model.getParentId());
condition.put("Id_n_neq", 1);
condition.put("Id_s_order", "asc");
materialCategoryService.find(pageUtil);
mapData.put("materialCategoryList", 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
{
MaterialCategory materialCategory = new MaterialCategory();
materialCategory.setMaterialCategory(new MaterialCategory(model.getParentId()));
materialCategory.setCategoryLevel(model.getCategoryLevel());
materialCategory.setName(model.getName());
materialCategoryService.create(materialCategory);
//========标识位===========
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
{
materialCategoryService.delete(model.getMaterialCategoryID());
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getMaterialCategoryID() + " 的商品类别异常", e);
tipMsg = "失败";
tipType = 1;
}
model.getShowModel().setMsgTip(tipMsg);
logService.create(new Logdetails(getUser(), "删除商品类别", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "删除商品类别ID为 "+ model.getMaterialCategoryID() + " " + tipMsg + "!", "删除商品类别" + tipMsg));
Log.infoFileSync("====================结束调用删除商品类别信息方法delete()================");
return SUCCESS;
}
/**
* 更新商品类别
* @return
*/
public void update()
{
Boolean flag = false;
try
{
MaterialCategory materialCategory = materialCategoryService.get(model.getMaterialCategoryID());
materialCategory.setMaterialCategory(new MaterialCategory(model.getParentId()));
materialCategory.setCategoryLevel(model.getCategoryLevel());
materialCategory.setName(model.getName());
materialCategoryService.update(materialCategory);
flag = true;
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>修改商品类别ID为 : " + model.getMaterialCategoryID() + "信息失败", 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.getMaterialCategoryID() + " " + tipMsg + "!", "更新商品类别" + tipMsg));
}
/**
* 批量删除指定ID商品类别
* @return
*/
public String batchDelete()
{
try
{
materialCategoryService.batchDelete(model.getMaterialCategoryIDs());
model.getShowModel().setMsgTip("成功");
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>批量删除商品类别ID为:" + model.getMaterialCategoryIDs() + "信息异常", e);
tipMsg = "失败";
tipType = 1;
}
logService.create(new Logdetails(getUser(), "批量删除商品类别", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "批量删除商品类别ID为 "+ model.getMaterialCategoryIDs() + " " + tipMsg + "!", "批量删除商品类别" + tipMsg));
return SUCCESS;
}
/**
* 查找商品类别信息
* @return
*/
public void findBy()
{
try
{
PageUtil<MaterialCategory> pageUtil = new PageUtil<MaterialCategory>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition());
materialCategoryService.find(pageUtil);
List<MaterialCategory> 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(MaterialCategory materialCategory:dataList)
{
JSONObject item = new JSONObject();
item.put("Id", materialCategory.getId());
item.put("ParentId", materialCategory.getMaterialCategory().getId());
item.put("ParentName", materialCategory.getMaterialCategory().getName());
item.put("CategoryLevel", materialCategory.getCategoryLevel());
item.put("Name", materialCategory.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
*/
private Map<String,Object> getCondition()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("ParentId_n_eq", model.getParentId());
condition.put("Id_n_neq", 1);
condition.put("Id_s_order", "asc");
return condition;
}
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
@Override
public MaterialCategoryModel getModel()
{
return model;
}
public void setMaterialCategoryService(MaterialCategoryIService materialCategoryService)
{
this.materialCategoryService = materialCategoryService;
}
}
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.MaterialCategory;
import com.jsh.model.po.Logdetails;
import com.jsh.model.vo.materials.MaterialCategoryModel;
import com.jsh.service.materials.MaterialCategoryIService;
import com.jsh.util.PageUtil;
/*
* 商品类型管理
* @author jishenghua qq:752718920
*/
@SuppressWarnings("serial")
public class MaterialCategoryAction extends BaseAction<MaterialCategoryModel>
{
private MaterialCategoryIService materialCategoryService;
private MaterialCategoryModel model = new MaterialCategoryModel();
@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("ParentId_n_eq", model.getParentId());
condition.put("Id_n_neq", 1);
condition.put("Id_s_order", "asc");
materialCategoryService.find(pageUtil);
mapData.put("materialCategoryList", 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
{
MaterialCategory materialCategory = new MaterialCategory();
materialCategory.setMaterialCategory(new MaterialCategory(model.getParentId()));
materialCategory.setCategoryLevel(model.getCategoryLevel());
materialCategory.setName(model.getName());
materialCategoryService.create(materialCategory);
//========标识位===========
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
{
materialCategoryService.delete(model.getMaterialCategoryID());
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getMaterialCategoryID() + " 的商品类别异常", e);
tipMsg = "失败";
tipType = 1;
}
model.getShowModel().setMsgTip(tipMsg);
logService.create(new Logdetails(getUser(), "删除商品类别", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "删除商品类别ID为 "+ model.getMaterialCategoryID() + " " + tipMsg + "!", "删除商品类别" + tipMsg));
Log.infoFileSync("====================结束调用删除商品类别信息方法delete()================");
return SUCCESS;
}
/**
* 更新商品类别
* @return
*/
public void update()
{
Boolean flag = false;
try
{
MaterialCategory materialCategory = materialCategoryService.get(model.getMaterialCategoryID());
materialCategory.setMaterialCategory(new MaterialCategory(model.getParentId()));
materialCategory.setCategoryLevel(model.getCategoryLevel());
materialCategory.setName(model.getName());
materialCategoryService.update(materialCategory);
flag = true;
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>修改商品类别ID为 : " + model.getMaterialCategoryID() + "信息失败", 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.getMaterialCategoryID() + " " + tipMsg + "!", "更新商品类别" + tipMsg));
}
/**
* 批量删除指定ID商品类别
* @return
*/
public String batchDelete()
{
try
{
materialCategoryService.batchDelete(model.getMaterialCategoryIDs());
model.getShowModel().setMsgTip("成功");
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>批量删除商品类别ID为:" + model.getMaterialCategoryIDs() + "信息异常", e);
tipMsg = "失败";
tipType = 1;
}
logService.create(new Logdetails(getUser(), "批量删除商品类别", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "批量删除商品类别ID为 "+ model.getMaterialCategoryIDs() + " " + tipMsg + "!", "批量删除商品类别" + tipMsg));
return SUCCESS;
}
/**
* 查找商品类别信息
* @return
*/
public void findBy()
{
try
{
PageUtil<MaterialCategory> pageUtil = new PageUtil<MaterialCategory>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition());
materialCategoryService.find(pageUtil);
List<MaterialCategory> 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(MaterialCategory materialCategory:dataList)
{
JSONObject item = new JSONObject();
item.put("Id", materialCategory.getId());
item.put("ParentId", materialCategory.getMaterialCategory().getId());
item.put("ParentName", materialCategory.getMaterialCategory().getName());
item.put("CategoryLevel", materialCategory.getCategoryLevel());
item.put("Name", materialCategory.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
*/
private Map<String,Object> getCondition()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("ParentId_n_eq", model.getParentId());
condition.put("Id_n_neq", 1);
condition.put("Id_s_order", "asc");
return condition;
}
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
@Override
public MaterialCategoryModel getModel()
{
return model;
}
public void setMaterialCategoryService(MaterialCategoryIService materialCategoryService)
{
this.materialCategoryService = materialCategoryService;
}
}
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.Person;
import com.jsh.model.po.Logdetails;
import com.jsh.model.vo.materials.PersonModel;
import com.jsh.service.materials.PersonIService;
import com.jsh.util.common.PageUtil;
@SuppressWarnings("serial")
public class PersonAction extends BaseAction<PersonModel>
{
private PersonIService personService;
private PersonModel model = new PersonModel();
@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");
personService.find(pageUtil);
mapData.put("personList", 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
{
Person person = new Person();
person.setDepot(new Depot(model.getProjectId()));
person.setType(model.getType());
person.setName(model.getName());
personService.create(person);
//========标识位===========
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
{
personService.delete(model.getPersonID());
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getPersonID() + " 的经手人异常", e);
tipMsg = "失败";
tipType = 1;
}
model.getShowModel().setMsgTip(tipMsg);
logService.create(new Logdetails(getUser(), "删除经手人", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "删除经手人ID为 "+ model.getPersonID() + " " + tipMsg + "!", "删除经手人" + tipMsg));
Log.infoFileSync("====================结束调用删除经手人信息方法delete()================");
return SUCCESS;
}
/**
* 更新经手人
* @return
*/
public void update()
{
Boolean flag = false;
try
{
Person person = personService.get(model.getPersonID());
person.setDepot(new Depot(model.getProjectId()));
person.setType(model.getType());
person.setName(model.getName());
personService.update(person);
flag = true;
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>修改经手人ID为 : " + model.getPersonID() + "信息失败", 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.getPersonID() + " " + tipMsg + "!", "更新经手人" + tipMsg));
}
/**
* 批量删除指定ID经手人
* @return
*/
public String batchDelete()
{
try
{
personService.batchDelete(model.getPersonIDs());
model.getShowModel().setMsgTip("成功");
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>批量删除经手人ID为:" + model.getPersonIDs() + "信息异常", e);
tipMsg = "失败";
tipType = 1;
}
logService.create(new Logdetails(getUser(), "批量删除经手人", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "批量删除经手人ID为 "+ model.getPersonIDs() + " " + tipMsg + "!", "批量删除经手人" + tipMsg));
return SUCCESS;
}
/**
* 查找经手人信息
* @return
*/
public void findBy()
{
try
{
PageUtil<Person> pageUtil = new PageUtil<Person>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition());
personService.find(pageUtil);
List<Person> 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(Person person:dataList)
{
JSONObject item = new JSONObject();
item.put("Id", person.getId());
item.put("ProjectId", person.getDepot().getId());
item.put("ProjectName", person.getDepot().getName());
item.put("Type", person.getType());
item.put("Name", person.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
*/
private Map<String,Object> getCondition()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("ProjectId_n_eq", model.getProjectId());
condition.put("Type_s_eq", model.getType());
return condition;
}
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
@Override
public PersonModel getModel()
{
return model;
}
public void setPersonService(PersonIService personService)
{
this.personService = personService;
}
}
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.Person;
import com.jsh.model.po.Logdetails;
import com.jsh.model.vo.materials.PersonModel;
import com.jsh.service.materials.PersonIService;
import com.jsh.util.PageUtil;
/*
* 经手人管理
* @author jishenghua qq:752718920
*/
@SuppressWarnings("serial")
public class PersonAction extends BaseAction<PersonModel>
{
private PersonIService personService;
private PersonModel model = new PersonModel();
@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");
personService.find(pageUtil);
mapData.put("personList", pageUtil.getPageList());
}
catch (Exception e)
{
Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e);
model.getShowModel().setMsgTip("exceptoin");
}
return SUCCESS;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public String getPersonByType()
{
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("Type_s_eq", model.getType());
condition.put("Id_s_order", "asc");
personService.find(pageUtil);
mapData.put("personList", 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
{
Person person = new Person();
person.setDepot(new Depot(model.getProjectId()));
person.setType(model.getType());
person.setName(model.getName());
personService.create(person);
//========标识位===========
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
{
personService.delete(model.getPersonID());
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getPersonID() + " 的经手人异常", e);
tipMsg = "失败";
tipType = 1;
}
model.getShowModel().setMsgTip(tipMsg);
logService.create(new Logdetails(getUser(), "删除经手人", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "删除经手人ID为 "+ model.getPersonID() + " " + tipMsg + "!", "删除经手人" + tipMsg));
Log.infoFileSync("====================结束调用删除经手人信息方法delete()================");
return SUCCESS;
}
/**
* 更新经手人
* @return
*/
public void update()
{
Boolean flag = false;
try
{
Person person = personService.get(model.getPersonID());
person.setDepot(new Depot(model.getProjectId()));
person.setType(model.getType());
person.setName(model.getName());
personService.update(person);
flag = true;
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>修改经手人ID为 : " + model.getPersonID() + "信息失败", 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.getPersonID() + " " + tipMsg + "!", "更新经手人" + tipMsg));
}
/**
* 批量删除指定ID经手人
* @return
*/
public String batchDelete()
{
try
{
personService.batchDelete(model.getPersonIDs());
model.getShowModel().setMsgTip("成功");
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>批量删除经手人ID为:" + model.getPersonIDs() + "信息异常", e);
tipMsg = "失败";
tipType = 1;
}
logService.create(new Logdetails(getUser(), "批量删除经手人", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "批量删除经手人ID为 "+ model.getPersonIDs() + " " + tipMsg + "!", "批量删除经手人" + tipMsg));
return SUCCESS;
}
/**
* 查找经手人信息
* @return
*/
public void findBy()
{
try
{
PageUtil<Person> pageUtil = new PageUtil<Person>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition());
personService.find(pageUtil);
List<Person> 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(Person person:dataList)
{
JSONObject item = new JSONObject();
item.put("Id", person.getId());
item.put("ProjectId", person.getDepot().getId());
item.put("ProjectName", person.getDepot().getName());
item.put("Type", person.getType());
item.put("Name", person.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
*/
private Map<String,Object> getCondition()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("ProjectId_n_eq", model.getProjectId());
condition.put("Type_s_eq", model.getType());
return condition;
}
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
@Override
public PersonModel getModel()
{
return model;
}
public void setPersonService(PersonIService personService)
{
this.personService = personService;
}
}
......@@ -15,7 +15,7 @@ import com.jsh.model.po.Basicuser;
import com.jsh.service.basic.LogIService;
/**
* struts2工具类
* @author jishenghua
* @author jishenghua qq752718920
* struts2 base action 一些常用方法获取
*/
@SuppressWarnings("serial")
......
......@@ -8,11 +8,11 @@ import org.hibernate.Query;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.jsh.util.common.PageUtil;
import com.jsh.util.common.SearchConditionUtil;
import com.jsh.util.PageUtil;
import com.jsh.util.SearchConditionUtil;
/**
* 基础dao
* @author ji_sheng_hua
* @author ji_sheng_hua qq:752718920
*/
public class BaseDAO<T> extends HibernateDaoSupport implements BaseIDAO<T>
{
......
......@@ -6,11 +6,11 @@ import java.util.Map;
import org.springframework.dao.DataAccessException;
import com.jsh.util.common.PageUtil;
import com.jsh.util.PageUtil;
/**
* 常用增删改查操作
* @author ji-sheng-hua
* @author ji-sheng-hua qq752718920
* @param <T>
*/
public interface BaseIDAO<T>
......
package com.jsh.base;
import java.io.Serializable;
import org.springframework.dao.DataAccessException;
import com.jsh.util.common.PageUtil;
public interface BaseIService<T>
{
/**
* 增加
* @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 id 对象ID
* @throws DataAccessException
*/
void delete(Long id)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 filedName 效验的字段名称
* @param filedVale 校验值
* @param idFiled ID字段名称
* @param objectID 修改时对象ID
* @return true==存在 false==不存在
* @throws DataAccessException
*/
Boolean checkIsNameExist(String filedName,String filedVale,String idFiled,Long objectID) throws DataAccessException;
/**
* 检查UserBusiness是否存在,页面唯一性效验使用
* @param TypeName 类型名称
* @param TypeVale 类型值
* @param KeyIdName 关键id
* @param KeyIdValue 关键值
* @param UBName 关系名称
* @param UBValue 关系值
* @return true==存在 false==不存在
* @throws DataAccessException
*/
Boolean checkIsUserBusinessExist(String TypeName,String TypeVale,String KeyIdName,String KeyIdValue,String UBName,String UBValue) throws DataAccessException;
/**
* 检查UserBusiness是否存在,页面唯一性效验使用
* @param TypeName 类型名称
* @param TypeVale 类型值
* @param KeyIdName 关键id
* @param KeyIdValue 关键值
* @return true==存在 false==不存在
* @throws DataAccessException
*/
Boolean checkIsValueExist(String TypeName, String TypeVale, String KeyIdName, String KeyIdValue) throws DataAccessException;
}
package com.jsh.base;
import java.io.Serializable;
import org.springframework.dao.DataAccessException;
import com.jsh.util.PageUtil;
/**
* 服务层底层接口
* @author ji-sheng-hua qq752718920
* @param <T>
*/
public interface BaseIService<T>
{
/**
* 增加
* @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 id 对象ID
* @throws DataAccessException
*/
void delete(Long id)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 filedName 效验的字段名称
* @param filedVale 校验值
* @param idFiled ID字段名称
* @param objectID 修改时对象ID
* @return true==存在 false==不存在
* @throws DataAccessException
*/
Boolean checkIsNameExist(String filedName,String filedVale,String idFiled,Long objectID) throws DataAccessException;
/**
* 检查UserBusiness是否存在,页面唯一性效验使用
* @param TypeName 类型名称
* @param TypeVale 类型值
* @param KeyIdName 关键id
* @param KeyIdValue 关键值
* @param UBName 关系名称
* @param UBValue 关系值
* @return true==存在 false==不存在
* @throws DataAccessException
*/
Boolean checkIsUserBusinessExist(String TypeName,String TypeVale,String KeyIdName,String KeyIdValue,String UBName,String UBValue) throws DataAccessException;
/**
* 检查UserBusiness是否存在,页面唯一性效验使用
* @param TypeName 类型名称
* @param TypeVale 类型值
* @param KeyIdName 关键id
* @param KeyIdValue 关键值
* @return true==存在 false==不存在
* @throws DataAccessException
*/
Boolean checkIsValueExist(String TypeName, String TypeVale, String KeyIdName, String KeyIdValue) throws DataAccessException;
}
......@@ -7,10 +7,14 @@ import java.util.Map;
import org.springframework.dao.DataAccessException;
import com.jsh.exception.JshException;
import com.jsh.util.JshException;
import com.jsh.model.po.Basicuser;
import com.jsh.util.common.PageUtil;
import com.jsh.util.PageUtil;
/**
* 底层服务层
* @author ji-sheng-hua qq752718920
* @param <T>
*/
public abstract class BaseService<T> implements BaseIService<T>
{
/**
......
......@@ -4,7 +4,7 @@ import org.apache.log4j.Logger;
/**
* 封装log4j日志信息,打印日志信息类
* @author ji/sheng/hua
* @author ji/sheng/hua qq_752718920
* @since 2014-01-22
*/
public class Log
......@@ -17,7 +17,7 @@ public class Log
/**
* 获取Log4j实例
*/
private static final Logger log = Logger.getLogger("ams");
private static final Logger log = Logger.getLogger("jsh");
/**
* Info级别日志前缀
......
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";
}
}
package com.jsh.constants.asset;
public interface ExcelConstantsCode
{
/**
* 导入excel表格常量定义
*/
public class ImportExcelCode
{
/**
* 表格正确
*/
public static final String RIGHT = "right";
/**
* 表格错误
*/
public static final String WRONG = "wrong";
/**
* 表格警告
*/
public static final String WARN = "warn";
}
/**
* 导出excel表格常量定义
* @author angel
*
*/
public class ExportExcelCode
{
}
}
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 = "##########";
}
}
package com.jsh.constants.common;
public interface ExceptionCodeConstants
{
/**
* 用户错误码定义
*/
public class UserExceptionCode
{
/**
* 用户不存在
*/
public static final int USER_NOT_EXIST = 1;
/**
* 用户密码错误
*/
public static final int USER_PASSWORD_ERROR = 2;
/**
* 被加入黑名单
*/
public static final int BLACK_USER = 3;
/**
* 可以登录
*/
public static final int USER_CONDITION_FIT = 4;
/**
* 访问数据库异常
*/
public static final int USER_ACCESS_EXCEPTION = 5;
}
}
package com.jsh.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 = "日志管理";
}
}
......@@ -3,10 +3,10 @@ package com.jsh.dao.asset;
import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.jsh.exception.JshException;
import com.jsh.util.JshException;
import com.jsh.model.po.Asset;
import com.jsh.util.common.PageUtil;
import com.jsh.util.common.SearchConditionUtil;
import com.jsh.util.PageUtil;
import com.jsh.util.SearchConditionUtil;
public class ReportDAO extends HibernateDaoSupport implements ReportIDAO
{
......
package com.jsh.dao.asset;
import com.jsh.exception.JshException;
import com.jsh.util.JshException;
import com.jsh.model.po.Asset;
import com.jsh.util.common.PageUtil;
import com.jsh.util.PageUtil;
public interface ReportIDAO
{
......
......@@ -3,11 +3,11 @@ package com.jsh.dao.basic;
import org.hibernate.Query;
import com.jsh.base.BaseDAO;
import com.jsh.exception.JshException;
import com.jsh.util.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;
import com.jsh.util.PageUtil;
import com.jsh.util.SearchConditionUtil;
public class UserBusinessDAO extends BaseDAO<UserBusiness> implements UserBusinessIDAO
{
......
package com.jsh.dao.basic;
import com.jsh.base.BaseIDAO;
import com.jsh.exception.JshException;
import com.jsh.util.JshException;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.common.PageUtil;
import com.jsh.util.PageUtil;
public interface UserBusinessIDAO extends BaseIDAO<UserBusiness>
{
......
package com.jsh.dao.materials;
import org.hibernate.Query;
import com.jsh.base.BaseDAO;
import com.jsh.util.JshException;
import com.jsh.model.po.AccountHead;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.PageUtil;
import com.jsh.util.SearchConditionUtil;
public class AccountHeadDAO extends BaseDAO<AccountHead> implements AccountHeadIDAO
{
/**
* 设置dao映射基类
* @return
*/
@Override
public Class<AccountHead> getEntityClass()
{
return AccountHead.class;
}
@SuppressWarnings("unchecked")
@Override
public void find(PageUtil<AccountHead> pageUtil,String maxid) throws JshException
{
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select max(Id) as Id from AccountHead accountHead where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
pageUtil.setTotalCount(query.list().size());
pageUtil.setPageList(query.list());
}
}
package com.jsh.dao.materials;
import com.jsh.base.BaseIDAO;
import com.jsh.util.JshException;
import com.jsh.model.po.AccountHead;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.PageUtil;
public interface AccountHeadIDAO extends BaseIDAO<AccountHead>
{
/*
* 获取MaxId
*/
void find(PageUtil<AccountHead> pageUtil,String maxid) throws JshException;
}
package com.jsh.dao.materials;
import org.hibernate.Query;
import com.jsh.base.BaseDAO;
import com.jsh.util.JshException;
import com.jsh.model.po.AccountItem;
import com.jsh.util.PageUtil;
import com.jsh.util.SearchConditionUtil;
public class AccountItemDAO extends BaseDAO<AccountItem> implements AccountItemIDAO
{
/**
* 设置dao映射基类
* @return
*/
@Override
public Class<AccountItem> getEntityClass()
{
return AccountItem.class;
}
}
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