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

no commit message

parent b8a2b074
package com.jsh.action.materials; package com.jsh.action.materials;
import java.io.IOException; import java.io.IOException;
import java.sql.Timestamp; import java.sql.Timestamp;
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 net.sf.json.JSONArray;
import net.sf.json.JSONArray; import net.sf.json.JSONObject;
import net.sf.json.JSONObject; import org.springframework.dao.DataAccessException;
import com.jsh.base.BaseAction;
import org.springframework.dao.DataAccessException; import com.jsh.base.Log;
import com.jsh.model.po.MaterialCategory;
import com.jsh.base.BaseAction; import com.jsh.model.po.Logdetails;
import com.jsh.base.Log; import com.jsh.model.vo.materials.MaterialCategoryModel;
import com.jsh.model.po.MaterialCategory; import com.jsh.service.materials.MaterialCategoryIService;
import com.jsh.model.po.Logdetails; import com.jsh.util.PageUtil;
import com.jsh.model.vo.materials.MaterialCategoryModel; /*
import com.jsh.service.materials.MaterialCategoryIService; * 商品类型管理
import com.jsh.util.common.PageUtil; * @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); Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加商品类别信息异常", 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, "增加商品类别名称为 "+ 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); Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getMaterialCategoryID() + " 的商品类别异常", e);
tipMsg = "失败"; 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); Log.errorFileSync(">>>>>>>>>>>批量删除商品类别ID为:" + model.getMaterialCategoryIDs() + "信息异常", e);
tipMsg = "失败"; 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"}
// ]} // ]}
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(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());
item.put("ParentName", materialCategory.getMaterialCategory().getName()); item.put("ParentName", materialCategory.getMaterialCategory().getName());
item.put("CategoryLevel", materialCategory.getCategoryLevel()); item.put("CategoryLevel", materialCategory.getCategoryLevel());
item.put("Name", materialCategory.getName()); item.put("Name", materialCategory.getName());
item.put("op", 1); item.put("op", 1);
dataArray.add(item); dataArray.add(item);
} }
} }
outer.put("rows", dataArray); outer.put("rows", dataArray);
//回写查询结果 //回写查询结果
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("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");
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;
} }
} }
package com.jsh.action.materials; package com.jsh.action.materials;
import java.io.IOException; import java.io.IOException;
import java.sql.Timestamp; import java.sql.Timestamp;
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 net.sf.json.JSONArray;
import net.sf.json.JSONArray; import net.sf.json.JSONObject;
import net.sf.json.JSONObject; import org.springframework.dao.DataAccessException;
import com.jsh.base.BaseAction;
import org.springframework.dao.DataAccessException; import com.jsh.base.Log;
import com.jsh.model.po.Depot;
import com.jsh.base.BaseAction; import com.jsh.model.po.Person;
import com.jsh.base.Log; import com.jsh.model.po.Logdetails;
import com.jsh.model.po.Depot; import com.jsh.model.vo.materials.PersonModel;
import com.jsh.model.po.Person; import com.jsh.service.materials.PersonIService;
import com.jsh.model.po.Logdetails; import com.jsh.util.PageUtil;
import com.jsh.model.vo.materials.PersonModel; /*
import com.jsh.service.materials.PersonIService; * 经手人管理
import com.jsh.util.common.PageUtil; * @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("ProjectId_n_eq", model.getProjectId()); condition.put("ProjectId_n_eq", model.getProjectId());
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" })
* 增加经手人 public String getPersonByType()
* @return {
*/ Map<String,List> mapData = model.getShowModel().getMap();
public void create() PageUtil pageUtil = new PageUtil();
{ pageUtil.setPageSize(0);
Log.infoFileSync("==================开始调用增加经手人信息方法create()==================="); pageUtil.setCurPage(0);
Boolean flag = false; try
try {
{ Map<String,Object> condition = pageUtil.getAdvSearch();
Person person = new Person(); condition.put("Type_s_eq", model.getType());
person.setDepot(new Depot(model.getProjectId())); condition.put("Id_s_order", "asc");
personService.find(pageUtil);
person.setType(model.getType()); mapData.put("personList", pageUtil.getPageList());
person.setName(model.getName()); }
personService.create(person); catch (Exception e)
{
//========标识位=========== Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e);
flag = true; model.getShowModel().setMsgTip("exceptoin");
//记录操作日志使用 }
tipMsg = "成功"; return SUCCESS;
tipType = 0; }
}
catch (DataAccessException e) /**
{ * 增加经手人
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加经手人信息异常", e); * @return
flag = false; */
tipMsg = "失败"; public void create()
tipType = 1; {
} Log.infoFileSync("==================开始调用增加经手人信息方法create()===================");
finally Boolean flag = false;
{ try
try {
{ Person person = new Person();
toClient(flag.toString()); person.setDepot(new Depot(model.getProjectId()));
}
catch (IOException e) person.setType(model.getType());
{ person.setName(model.getName());
Log.errorFileSync(">>>>>>>>>>>>增加经手人信息回写客户端结果异常", e); personService.create(person);
}
} //========标识位===========
flag = true;
logService.create(new Logdetails(getUser(), "增加经手人", model.getClientIp(), //记录操作日志使用
new Timestamp(System.currentTimeMillis()) tipMsg = "成功";
, tipType, "增加经手人名称为 "+ model.getName() + " " + tipMsg + "!", "增加经手人" + tipMsg)); tipType = 0;
Log.infoFileSync("==================结束调用增加经手人方法create()==================="); }
} catch (DataAccessException e)
{
/** Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加经手人信息异常", e);
* 删除经手人 flag = false;
* @return tipMsg = "失败";
*/ tipType = 1;
public String delete() }
{ finally
Log.infoFileSync("====================开始调用删除经手人信息方法delete()================"); {
try try
{ {
personService.delete(model.getPersonID()); toClient(flag.toString());
tipMsg = "成功"; }
tipType = 0; catch (IOException e)
} {
catch (DataAccessException e) Log.errorFileSync(">>>>>>>>>>>>增加经手人信息回写客户端结果异常", e);
{ }
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getPersonID() + " 的经手人异常", e); }
tipMsg = "失败";
tipType = 1; logService.create(new Logdetails(getUser(), "增加经手人", model.getClientIp(),
} new Timestamp(System.currentTimeMillis())
model.getShowModel().setMsgTip(tipMsg); , tipType, "增加经手人名称为 "+ model.getName() + " " + tipMsg + "!", "增加经手人" + tipMsg));
logService.create(new Logdetails(getUser(), "删除经手人", model.getClientIp(), Log.infoFileSync("==================结束调用增加经手人方法create()===================");
new Timestamp(System.currentTimeMillis()) }
, tipType, "删除经手人ID为 "+ model.getPersonID() + " " + tipMsg + "!", "删除经手人" + tipMsg));
Log.infoFileSync("====================结束调用删除经手人信息方法delete()================"); /**
return SUCCESS; * 删除经手人
} * @return
*/
/** public String delete()
* 更新经手人 {
* @return Log.infoFileSync("====================开始调用删除经手人信息方法delete()================");
*/ try
public void update() {
{ personService.delete(model.getPersonID());
Boolean flag = false; tipMsg = "成功";
try tipType = 0;
{ }
Person person = personService.get(model.getPersonID()); catch (DataAccessException e)
person.setDepot(new Depot(model.getProjectId())); {
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getPersonID() + " 的经手人异常", e);
person.setType(model.getType()); tipMsg = "失败";
person.setName(model.getName()); tipType = 1;
personService.update(person); }
model.getShowModel().setMsgTip(tipMsg);
flag = true; logService.create(new Logdetails(getUser(), "删除经手人", model.getClientIp(),
tipMsg = "成功"; new Timestamp(System.currentTimeMillis())
tipType = 0; , tipType, "删除经手人ID为 "+ model.getPersonID() + " " + tipMsg + "!", "删除经手人" + tipMsg));
} Log.infoFileSync("====================结束调用删除经手人信息方法delete()================");
catch (DataAccessException e) return SUCCESS;
{ }
Log.errorFileSync(">>>>>>>>>>>>>修改经手人ID为 : " + model.getPersonID() + "信息失败", e);
flag = false; /**
tipMsg = "失败"; * 更新经手人
tipType = 1; * @return
} */
finally public void update()
{ {
try Boolean flag = false;
{ try
toClient(flag.toString()); {
} Person person = personService.get(model.getPersonID());
catch (IOException e) person.setDepot(new Depot(model.getProjectId()));
{
Log.errorFileSync(">>>>>>>>>>>>修改经手人回写客户端结果异常", e); person.setType(model.getType());
} person.setName(model.getName());
} personService.update(person);
logService.create(new Logdetails(getUser(), "更新经手人", model.getClientIp(),
new Timestamp(System.currentTimeMillis()) flag = true;
, tipType, "更新经手人ID为 "+ model.getPersonID() + " " + tipMsg + "!", "更新经手人" + tipMsg)); tipMsg = "成功";
} tipType = 0;
}
/** catch (DataAccessException e)
* 批量删除指定ID经手人 {
* @return Log.errorFileSync(">>>>>>>>>>>>>修改经手人ID为 : " + model.getPersonID() + "信息失败", e);
*/ flag = false;
public String batchDelete() tipMsg = "失败";
{ tipType = 1;
try }
{ finally
personService.batchDelete(model.getPersonIDs()); {
model.getShowModel().setMsgTip("成功"); try
//记录操作日志使用 {
tipMsg = "成功"; toClient(flag.toString());
tipType = 0; }
} catch (IOException e)
catch (DataAccessException e) {
{ Log.errorFileSync(">>>>>>>>>>>>修改经手人回写客户端结果异常", e);
Log.errorFileSync(">>>>>>>>>>>批量删除经手人ID为:" + model.getPersonIDs() + "信息异常", e); }
tipMsg = "失败"; }
tipType = 1; logService.create(new Logdetails(getUser(), "更新经手人", model.getClientIp(),
} new Timestamp(System.currentTimeMillis())
, tipType, "更新经手人ID为 "+ model.getPersonID() + " " + tipMsg + "!", "更新经手人" + tipMsg));
logService.create(new Logdetails(getUser(), "批量删除经手人", model.getClientIp(), }
new Timestamp(System.currentTimeMillis())
, tipType, "批量删除经手人ID为 "+ model.getPersonIDs() + " " + tipMsg + "!", "批量删除经手人" + tipMsg)); /**
return SUCCESS; * 批量删除指定ID经手人
} * @return
*/
/** public String batchDelete()
* 查找经手人信息 {
* @return try
*/ {
public void findBy() personService.batchDelete(model.getPersonIDs());
{ model.getShowModel().setMsgTip("成功");
try //记录操作日志使用
{ tipMsg = "成功";
PageUtil<Person> pageUtil = new PageUtil<Person>(); tipType = 0;
pageUtil.setPageSize(model.getPageSize()); }
pageUtil.setCurPage(model.getPageNo()); catch (DataAccessException e)
pageUtil.setAdvSearch(getCondition()); {
personService.find(pageUtil); Log.errorFileSync(">>>>>>>>>>>批量删除经手人ID为:" + model.getPersonIDs() + "信息异常", e);
List<Person> dataList = pageUtil.getPageList(); tipMsg = "失败";
tipType = 1;
//开始拼接json数据 }
// {"total":28,"rows":[
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"} logService.create(new Logdetails(getUser(), "批量删除经手人", model.getClientIp(),
// ]} new Timestamp(System.currentTimeMillis())
JSONObject outer = new JSONObject(); , tipType, "批量删除经手人ID为 "+ model.getPersonIDs() + " " + tipMsg + "!", "批量删除经手人" + tipMsg));
outer.put("total", pageUtil.getTotalCount()); return SUCCESS;
//存放数据json数组 }
JSONArray dataArray = new JSONArray();
if(null != dataList) /**
{ * 查找经手人信息
for(Person person:dataList) * @return
{ */
JSONObject item = new JSONObject(); public void findBy()
item.put("Id", person.getId()); {
item.put("ProjectId", person.getDepot().getId()); try
item.put("ProjectName", person.getDepot().getName()); {
item.put("Type", person.getType()); PageUtil<Person> pageUtil = new PageUtil<Person>();
item.put("Name", person.getName()); pageUtil.setPageSize(model.getPageSize());
item.put("op", 1); pageUtil.setCurPage(model.getPageNo());
dataArray.add(item); pageUtil.setAdvSearch(getCondition());
} personService.find(pageUtil);
} List<Person> dataList = pageUtil.getPageList();
outer.put("rows", dataArray);
//回写查询结果 //开始拼接json数据
toClient(outer.toString()); // {"total":28,"rows":[
} // {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
catch (DataAccessException e) // ]}
{ JSONObject outer = new JSONObject();
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找经手人信息异常", e); outer.put("total", pageUtil.getTotalCount());
} //存放数据json数组
catch (IOException e) JSONArray dataArray = new JSONArray();
{ if(null != dataList)
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询经手人信息结果异常", e); {
} for(Person person:dataList)
} {
JSONObject item = new JSONObject();
/** item.put("Id", person.getId());
* 拼接搜索条件 item.put("ProjectId", person.getDepot().getId());
* @return item.put("ProjectName", person.getDepot().getName());
*/ item.put("Type", person.getType());
private Map<String,Object> getCondition() item.put("Name", person.getName());
{ item.put("op", 1);
/** dataArray.add(item);
* 拼接搜索条件 }
*/ }
Map<String,Object> condition = new HashMap<String,Object>(); outer.put("rows", dataArray);
condition.put("ProjectId_n_eq", model.getProjectId()); //回写查询结果
condition.put("Type_s_eq", model.getType()); toClient(outer.toString());
return condition; }
} catch (DataAccessException e)
{
//=============以下spring注入以及Model驱动公共方法,与Action处理无关================== Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找经手人信息异常", e);
@Override }
public PersonModel getModel() catch (IOException e)
{ {
return model; Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询经手人信息结果异常", e);
} }
public void setPersonService(PersonIService personService) }
{
this.personService = personService; /**
} * 拼接搜索条件
} * @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; ...@@ -15,7 +15,7 @@ import com.jsh.model.po.Basicuser;
import com.jsh.service.basic.LogIService; import com.jsh.service.basic.LogIService;
/** /**
* struts2工具类 * struts2工具类
* @author jishenghua * @author jishenghua qq752718920
* struts2 base action 一些常用方法获取 * struts2 base action 一些常用方法获取
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
......
...@@ -8,11 +8,11 @@ import org.hibernate.Query; ...@@ -8,11 +8,11 @@ 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.common.PageUtil; import com.jsh.util.PageUtil;
import com.jsh.util.common.SearchConditionUtil; import com.jsh.util.SearchConditionUtil;
/** /**
* 基础dao * 基础dao
* @author ji_sheng_hua * @author ji_sheng_hua qq:752718920
*/ */
public class BaseDAO<T> extends HibernateDaoSupport implements BaseIDAO<T> public class BaseDAO<T> extends HibernateDaoSupport implements BaseIDAO<T>
{ {
......
...@@ -6,11 +6,11 @@ import java.util.Map; ...@@ -6,11 +6,11 @@ import java.util.Map;
import org.springframework.dao.DataAccessException; 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> * @param <T>
*/ */
public interface BaseIDAO<T> public interface BaseIDAO<T>
......
package com.jsh.base; package com.jsh.base;
import java.io.Serializable; import java.io.Serializable;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import com.jsh.util.common.PageUtil; import com.jsh.util.PageUtil;
/**
public interface BaseIService<T> * 服务层底层接口
{ * @author ji-sheng-hua qq752718920
/** * @param <T>
* 增加 */
* @param t 对象 public interface BaseIService<T>
* @throws DataAccessException {
*/ /**
Serializable create(T t)throws DataAccessException; * 增加
* @param t 对象
/** * @throws DataAccessException
* 增加 */
* @param t 对象 Serializable create(T t)throws DataAccessException;
* @throws DataAccessException
*/ /**
void save(T t)throws DataAccessException; * 增加
* @param t 对象
/** * @throws DataAccessException
* 删除 */
* @param t 对象 void save(T t)throws DataAccessException;
* @throws DataAccessException
*/ /**
void delete(T t)throws DataAccessException; * 删除
* @param t 对象
/** * @throws DataAccessException
* 删除 */
* @param id 对象ID void delete(T t)throws DataAccessException;
* @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
* 修改信息 */
* @param t 要修改的对象 T get(Long objID)throws DataAccessException;
* @throws DataAccessException
*/ /**
void update(T t)throws DataAccessException; * 修改信息
* @param t 要修改的对象
/** * @throws DataAccessException
* 批量删除信息 */
* @param 以逗号分割的ID void update(T t)throws DataAccessException;
* @throws DataAccessException
*/ /**
void batchDelete(String objIDs)throws DataAccessException; * 批量删除信息
* @param 以逗号分割的ID
/** * @throws DataAccessException
* 查找列表 */
* @param pageUtil 分页工具类 void batchDelete(String objIDs)throws DataAccessException;
* @throws DataAccessException
*/ /**
void find(PageUtil<T> pageUtil) throws DataAccessException; * 查找列表
* @param pageUtil 分页工具类
/** * @throws DataAccessException
* 检查名称是否存在,页面唯一性效验使用 */
* @param filedName 效验的字段名称 void find(PageUtil<T> pageUtil) throws DataAccessException;
* @param filedVale 校验值
* @param idFiled ID字段名称 /**
* @param objectID 修改时对象ID * 检查名称是否存在,页面唯一性效验使用
* @return true==存在 false==不存在 * @param filedName 效验的字段名称
* @throws DataAccessException * @param filedVale 校验值
*/ * @param idFiled ID字段名称
Boolean checkIsNameExist(String filedName,String filedVale,String idFiled,Long objectID) throws DataAccessException; * @param objectID 修改时对象ID
* @return true==存在 false==不存在
/** * @throws DataAccessException
* 检查UserBusiness是否存在,页面唯一性效验使用 */
* @param TypeName 类型名称 Boolean checkIsNameExist(String filedName,String filedVale,String idFiled,Long objectID) throws DataAccessException;
* @param TypeVale 类型值
* @param KeyIdName 关键id /**
* @param KeyIdValue 关键值 * 检查UserBusiness是否存在,页面唯一性效验使用
* @param UBName 关系名称 * @param TypeName 类型名称
* @param UBValue 关系值 * @param TypeVale 类型值
* @return true==存在 false==不存在 * @param KeyIdName 关键id
* @throws DataAccessException * @param KeyIdValue 关键值
*/ * @param UBName 关系名称
Boolean checkIsUserBusinessExist(String TypeName,String TypeVale,String KeyIdName,String KeyIdValue,String UBName,String UBValue) throws DataAccessException; * @param UBValue 关系值
* @return true==存在 false==不存在
/** * @throws DataAccessException
* 检查UserBusiness是否存在,页面唯一性效验使用 */
* @param TypeName 类型名称 Boolean checkIsUserBusinessExist(String TypeName,String TypeVale,String KeyIdName,String KeyIdValue,String UBName,String UBValue) throws DataAccessException;
* @param TypeVale 类型值
* @param KeyIdName 关键id /**
* @param KeyIdValue 关键值 * 检查UserBusiness是否存在,页面唯一性效验使用
* @return true==存在 false==不存在 * @param TypeName 类型名称
* @throws DataAccessException * @param TypeVale 类型值
*/ * @param KeyIdName 关键id
Boolean checkIsValueExist(String TypeName, String TypeVale, String KeyIdName, String KeyIdValue) throws DataAccessException; * @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; ...@@ -7,10 +7,14 @@ import java.util.Map;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import com.jsh.exception.JshException; import com.jsh.util.JshException;
import com.jsh.model.po.Basicuser; 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> public abstract class BaseService<T> implements BaseIService<T>
{ {
/** /**
......
...@@ -4,7 +4,7 @@ import org.apache.log4j.Logger; ...@@ -4,7 +4,7 @@ import org.apache.log4j.Logger;
/** /**
* 封装log4j日志信息,打印日志信息类 * 封装log4j日志信息,打印日志信息类
* @author ji/sheng/hua * @author ji/sheng/hua qq_752718920
* @since 2014-01-22 * @since 2014-01-22
*/ */
public class Log public class Log
...@@ -17,7 +17,7 @@ public class Log ...@@ -17,7 +17,7 @@ public class Log
/** /**
* 获取Log4j实例 * 获取Log4j实例
*/ */
private static final Logger log = Logger.getLogger("ams"); private static final Logger log = Logger.getLogger("jsh");
/** /**
* Info级别日志前缀 * 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; ...@@ -3,10 +3,10 @@ package com.jsh.dao.asset;
import org.hibernate.Query; import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport; 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.model.po.Asset;
import com.jsh.util.common.PageUtil; import com.jsh.util.PageUtil;
import com.jsh.util.common.SearchConditionUtil; import com.jsh.util.SearchConditionUtil;
public class ReportDAO extends HibernateDaoSupport implements ReportIDAO public class ReportDAO extends HibernateDaoSupport implements ReportIDAO
{ {
......
package com.jsh.dao.asset; package com.jsh.dao.asset;
import com.jsh.exception.JshException; import com.jsh.util.JshException;
import com.jsh.model.po.Asset; import com.jsh.model.po.Asset;
import com.jsh.util.common.PageUtil; import com.jsh.util.PageUtil;
public interface ReportIDAO public interface ReportIDAO
{ {
......
...@@ -3,11 +3,11 @@ package com.jsh.dao.basic; ...@@ -3,11 +3,11 @@ package com.jsh.dao.basic;
import org.hibernate.Query; import org.hibernate.Query;
import com.jsh.base.BaseDAO; 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.Asset;
import com.jsh.model.po.UserBusiness; import com.jsh.model.po.UserBusiness;
import com.jsh.util.common.PageUtil; import com.jsh.util.PageUtil;
import com.jsh.util.common.SearchConditionUtil; import com.jsh.util.SearchConditionUtil;
public class UserBusinessDAO extends BaseDAO<UserBusiness> implements UserBusinessIDAO public class UserBusinessDAO extends BaseDAO<UserBusiness> implements UserBusinessIDAO
{ {
......
package com.jsh.dao.basic; package com.jsh.dao.basic;
import com.jsh.base.BaseIDAO; import com.jsh.base.BaseIDAO;
import com.jsh.exception.JshException; import com.jsh.util.JshException;
import com.jsh.model.po.UserBusiness; import com.jsh.model.po.UserBusiness;
import com.jsh.util.common.PageUtil; import com.jsh.util.PageUtil;
public interface UserBusinessIDAO extends BaseIDAO<UserBusiness> 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